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?
posted 15 years ago
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.