Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Ron McLeod
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Java in General
Serializing a ByteArrayOutputStream
Mahesh Trikannad
Ranch Hand
Posts: 73
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 24207
46
I like...
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 73
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Actually I need to. The framework iam using, requires the objects I pass to be serializable
Mahesh Trikannad
Jim Yingst
Wanderer
Posts: 18671
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 73
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks. Guess this question belonged to the Beginner
Mahesh Trikannad
I once met a man from Nantucket. He had a tiny ad
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Object Transformer serialize problem
java.io. NotSerializableException: java.io.ByteArrayOutputStream
Serialize an object to db2
serialization
Serialization Problem
More...