• Post Reply Bookmark Topic Watch Topic
  • New Topic

Byte arrays to save serialized objects?  RSS feed

 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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?
 
Henry Wong
author
Sheriff
Posts: 22852
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!