aspose file tools
The moose likes Java in General and the fly likes Serializing a ByteArrayOutputStream Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Serializing a ByteArrayOutputStream" Watch "Serializing a ByteArrayOutputStream" New topic
Author

Serializing a ByteArrayOutputStream

Mahesh Trikannad
Ranch Hand

Joined: Dec 14, 2004
Posts: 66
I have access to a ByteArrayOutputStream. The byte stream contains a PDF.

I need to serialize it to send it over the network.

Doing a toString() I suspect may corrupt the data.

How do I serialize the byte array.

Mahesh


Mahesh Trikannad
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24051
    
  13

Get the data with toByteArray(), then send that. Don't bother with serialization (unless you need to, for some reason); just send the raw bytes -- it will be faster.


[Jess in Action][AskingGoodQuestions]
Mahesh Trikannad
Ranch Hand

Joined: Dec 14, 2004
Posts: 66
Actually I need to. The framework iam using, requires the objects I pass to be serializable
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18670
So pass the byte array returned by toByteArray(), which is serializable like all primitive arrays.


"I'm not back." - Bill Harding, Twister
Mahesh Trikannad
Ranch Hand

Joined: Dec 14, 2004
Posts: 66
Thanks. Guess this question belonged to the Beginner
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Serializing a ByteArrayOutputStream
 
Similar Threads
Serialize an object to db2
serialization
java.io. NotSerializableException: java.io.ByteArrayOutputStream
Serialization Problem
Object Transformer serialize problem