I don't know much Java. Does 'System.in.read(buffer)' block until stdin is at EOF or buffer is full? Then this solution would be somewhat broken. Imagine a low-bandwidth source on stdin and a audio player connected to stdout, like wget -O - http://audiostream | java inout.java | mplayer /dev/stdin If I had to write this in C I'd use file descriptors in non-blocking mode and select(). With Tcl one could use event-base…
[1] http://docs.oracle.com/javase/7/docs/api/java/io/InputStream...