如何解决java.io.IOException:lseek失败:在Android中读取PIPE时ESPIPE(非法搜索)?

时间:2016-08-04 12:30:28

标签: java android pipe

我在Android中开发。我尝试实现 PIPE ,我读了PIPE文件,如下面的代码:

public void onClick(View view) {
        switch (view.getId()) {
               case R.id.iat_recognize_stream:

                new Thread(new Runnable(){
                    @Override
                    public void run() {
                        // TODO Auto-generated method stub
                        while(true){
                            try{
                                File vSDCard = null;

                                vSDCard = Environment.getExternalStorageDirectory();

                                File vPath = new File( vSDCard.getParent() + "/legacy/rcfifo" );
                                // Connect to the named pipe
                                RandomAccessFile pipe = new RandomAccessFile(vPath, "r"); // "r" or "w" or for bidirectional (Windows only) "rw"

                                // Read response from pipe
                                String string_data= pipe.readLine();
                                byte[] byte_data = string_data.getBytes();
                                Log.d(TAG,"test log");


                                if(false){
                                    pipe.close();
                                }
                            }
                            catch(Exception e){
                                Log.d(TAG,"test Exception = " + e.toString());
                            }
                        }
                    }
                }).start();

            break;
        }
    }

在以下日志中,它会显示 java.io.IOException: lseek failed: ESPIPE

D/IatDemo: test Exception = java.io.IOException: lseek failed: ESPIPE (Illegal seek)
D/IatDemo: test log 
D/IatDemo: test log 
D/IatDemo: test Exception = java.io.IOException: lseek failed: ESPIPE (Illegal seek)
D/IatDemo: test Exception = java.io.IOException: lseek failed: ESPIPE (Illegal seek)

问题1:

如何解决java.io.IOException:lseek失败:在Android中读取PIPE时ESPIPE(非法搜索)?

问题2: 如何通过Log?

打印十六进制的所有字节数据

0 个答案:

没有答案