How to convert outputstream into inputStream
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   kate_M
Posted On:   Tuesday, May 25, 2004 10:54 AM

Hi
Can someone tell me how to
convert outputStream into an input Stream
Thanks

Re: How to convert outputstream into inputStream

Posted By:   Sean_Owen  
Posted On:   Tuesday, May 25, 2004 11:52 AM

Well you can't do that, since an output stream is something you write to, and an input stream is something you read from. What would such a conversion mean?



If you want to read all available bytes from an output stream, and write them to an input stream, you will just need to write a loop:




InputStream in = ...;
OutputStream out = ...;

int bytesRead;
byte[] buffer = new byte[2048];
while ((bytesRead = in.read(buffer)) > 0) {
out.write(buffer, 0, bytesRead);
}
About | Sitemap | Contact