Pipe data from InputStream to OutputStream in Java
Posted
by Wangnick
on Stack Overflow
See other posts from Stack Overflow
or by Wangnick
Published on 2010-04-17T20:44:40Z
Indexed on
2010/04/17
21:13 UTC
Read the original article
Hit count: 395
Dear all,
I'd like to send a file contained in a ZIP archive unzipped to an external program for further decoding and to read the result back into Java.
ZipInputStream zis = new ZipInputStream(new FileInputStream(ZIPPATH));
Process decoder = new ProcessBuilder(DECODER).start();
???
BufferedReader br = new BufferedReader(new InputStreamReader(
decoder.getInputStream(),"us-ascii"));
for (String line = br.readLine(); line!=null; line = br.readLine()) {
...
}
What do I need to put into ???
to pipe the zis
content to the decoder.getOutputStream()
? I guess a dedicated thread is needed, as the decoder process might block when its output is not consumed.
© Stack Overflow or respective owner