File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Byte arrays to save serialized objects? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Byte arrays to save serialized objects?" Watch "Byte arrays to save serialized objects?" New topic
Author

Byte arrays to save serialized objects?

Jon Camilleri
Ranch Hand

Joined: Apr 25, 2008
Posts: 660

"The Preferences repository has a tree structure, with node path names such as /com/mycom-
pany/myapp. As with package names, name clashes are avoided as long as programmers
start the paths with reversed domain names. In fact, the designers of the API suggest
that the configuration node paths match the package names in your program.
Each node in the repository has a separate table of key/value pairs that you can use to
store numbers, strings, or byte arrays. No provision is made for storing serializable
objects.

The API designers felt that the serialization format is too fragile for long-term
storage. Of course, if you disagree, you can save serialized objects in byte arrays."

Core Java Volume I (8th Edition) P.544

Does anyone have an example of using byte arrays to save serialized objects?

Jon
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19072
    
  40

Jon Camilleri wrote:
Does anyone have an example of using byte arrays to save serialized objects?


It's actually fairly easy to figure out on your own.

Serialization is done with the ObjectOutputStream and ObjectInputStream classes. These classes take OutputStream and InputStream respectively. And there are byte array versions of this stream.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Byte arrays to save serialized objects?