使用Fedora 12:
当我使用以下代码尝试打开针对该命名管道的输入流时,除非我创建一个写入器向该管道写入数据,否则它会在FileInputStream构造函数处阻塞,例如在另一个终端窗口中运行:
mkfifo pipe
创建了一个命名管道。当我使用以下代码尝试打开针对该命名管道的输入流时,除非我创建一个写入器向该管道写入数据,否则它会在FileInputStream构造函数处阻塞,例如在另一个终端窗口中运行:
tee pipe
public static void main(String[] args){
try {
File pipe = new File("/tmp/pipes_debugging/pipeToJava");
System.out.println( pipe.canRead() );
FileInputStream fis = new FileInputStream(pipe);
System.out.println("exiting.");
} catch (Exception e) {
e.printStackTrace();
}
}
输出:
true
<blocks - thread trace shown below>
Thread [main] (Suspended)
FileInputStream.open(String) line: not available [native method]
FileInputStream.<init>(File) line: 137
PipesDebugging.main(String[]) line: 12