The moose likes I/O and Streams and the fly likes InputStream -> OutputStream Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Reply Bookmark "InputStream -> OutputStream" Watch "InputStream -> OutputStream" New topic
Author

InputStream -> OutputStream

mathew Jackson
Greenhorn

Joined: Jun 15, 2001
Posts: 12
Here is what I need to do. Inside a servlet I have an InputStream that is the result of calling getInputStream on a Process. This is stdout from a C program that I call. I also have an OutputStream. This comes from Response.getOutputStream. What I need to do is pipe the stream from the InputStream through the OutputStream.
Any ideas?
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18652
Write a loop to read bytes from the input stream, and write those bytes to the output stream:

For improved efficiency, modify the loop to use read(byte[]) and write(byte[]) instead. It may well also be useful to put this method in a separate thread.


"I'm not back." - Bill Harding, Twister
 
IntelliJ Java IDE
 
subject: InputStream -> OutputStream
 
Threads others viewed
Exception Question - antipattern
Convert byte stream to int
OutputStream -> InputStream
How to encode image in parts?
Convert InputStream to FileOutputStream
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture