How do I use Unix pipes with Java?

Nathan Meyers

Java doesn't give you direct access to non-portable capabilities like Unix/Linux pipes. You can still do quite a few things with pipes, for example:

  • Create a named pipe by invoking the mkfifo utility in a Runtime.exec() method.

  • Open a named pipe by name - which is just like opening a file.

  • Run an external process with Runtime.exec() and access its input and output streams via the Process.getInputStream() and Process.getOutputStream() methods.

If none of these solves the problem and you need to get to the pipe() system call, you'll need to write your own JNI code to do it.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact