Results 1 to 7 of 7
- 07-31-2008, 05:43 PM #1
Member
- Join Date
- Feb 2008
- Posts
- 60
- Rep Power
- 0
ByteArrayInputStream and ByteArrayOutputStream
Hi all,
I am getting the content of a source object which is returned as ByteArrayInputStream, and then I am assigning to a target object, which accepts input as ByteArrayOutputStream. Can someone please suggest as how can I convert ByteArrayInputStream to ByteArrayOutputStream, so that I can assigne it to my target object.
Here's my code:
Please advise...Java Code:ByteArrayInputStream content = source_object.getContent(); // how can I set the content of my source_object to the content of my target_object target_object.setContent(<it accepts a ByteArrayOutputStream>)
Thanks,
- 07-31-2008, 06:40 PM #2
Not sure what you mean by
other than to copy from one to the other.convert ByteArrayInputStream to ByteArrayOutputStream
Your request doesn't make sense. If setContent() wants an output stream, I would assume that the target_object class wants somewhere to WRITE something. An input stream is where there is something to be READ.
- 07-31-2008, 07:05 PM #3
Member
- Join Date
- Feb 2008
- Posts
- 60
- Rep Power
- 0
So, do I need to read the InputStream into a file and then write it to an OutputStream?
- 07-31-2008, 07:17 PM #4
It all depends on your application.
You can read an inputstream and write it to an outputstream without using a file.
- 07-31-2008, 08:01 PM #5
Member
- Join Date
- Feb 2008
- Posts
- 60
- Rep Power
- 0
- 07-31-2008, 09:39 PM #6
while((aByte = bais.read()) != -1)
baos.write(aByte);
- 07-31-2008, 10:02 PM #7
Member
- Join Date
- Feb 2008
- Posts
- 60
- Rep Power
- 0


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks