Streaming in serializable javabean

M

m

Hi all,

I am trying to build a serializable javabean.
What can I do with inputstream? Should I always read the whole stream and
put that into a byte[] attribute? This doesn't seem a good solution.
What else could I do?
Thanks.

m
 
J

John C. Bollinger

m said:
I am trying to build a serializable javabean.
What can I do with inputstream? Should I always read the whole stream and
put that into a byte[] attribute? This doesn't seem a good solution.
What else could I do?

It depends on the role your stream plays in the bean. The main options
I see are to serialize all the stream's data with the bean (you
mentioned the easiest way to do that) or to instead serialize the data
necessary to open and position a new stream when the bean is
deserialized. The former is inelegant, and swells the serialized
representation of the bean; the latter is problematic if the required
resource is not available at deserialization time.

My recommended solution is to not make beans that contain references to
stream objects. (Bean methods may manipulate any objects to which they
are given references, however.)


John Bollinger
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top