using UNIX pipes from Java

David Bullock db at dawnbreaks.net
Mon Nov 17 08:28:25 PST 2003


Hi folks,

I have a need to read a stream of data from some Perl
process into my Java program, but I can't guarantee
that the JVM will be started at the same time as the
Perl process, so the obvious solution of using System.in
doesn't seem applicable.

Using TCP sockets seems rather expensive, as the
process will be local.

So ... not knowing much about UNIX pipes beyond having
seen some odd things in the filesystem, I speculate:

1. sysadmin does does 'mkfifo /path/to/fifo'
2. Perl script opens the fifo write-only using black Perl magic
3. from Java I do:

   InputStream in = new FileInputStream("/path/to/fifo");

Am I on a good track?  Or are there better approaches?
I looked at java.nio, but the Pipe class doesn't take any
arguments.


(I realise this post is not strictly to do with the
FreeBSD Java port, so feel free to ignore me, but this
list seemed like a good place to place to ask for, uh,
pointers)

many thanks,
David



More information about the freebsd-java mailing list