| Author |
can an outputstream be serialised?
|
Moin Khatri
Greenhorn
Joined: Mar 18, 2007
Posts: 6
|
|
Hi, I am Moin.Please can anyone explain me whether an Output Stream be serialized or no and why. Thanks in advance, Moin
|
 |
Amir Alagic
Ranch Hand
Joined: Mar 21, 2006
Posts: 65
|
|
|
no, it is not possible to serialize OutputStream.
|
 |
Moin Khatri
Greenhorn
Joined: Mar 18, 2007
Posts: 6
|
|
thanks for the reply Amir.any explaination this context would be really helpful for me Cheers, Moieen
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
The short answer is, because no OutputStream (that I know of) implements the Serializable interface. Therefore, if you try to serialize it, you will get an exception. They didn't design these classes to be serializable because they didn't think it would be useful to anyone. I think you probably need to serialize the data written to the OutputStream. Can you tell us anything about the OutputStream you're using? Where did it come from? Did you create it, or did it come from some other class? What sort of data is being written to it? One possibly useful technique is to us a ByteArrayOutputStream for the OutputStream. When you are done writing to the stream, close() it, and then call toByteArray(). Now you have a byte[] which can be serialized.
|
"I'm not back." - Bill Harding, Twister
|
 |
 |
|
|
subject: can an outputstream be serialised?
|
|
|