I'm serializing my objects with ObjectOutputStream(FileOutputStream(File))
and deserializing them with the analogous InputStreams
. Is there a way to look inside of these serialized files (in eclipse preferably), so I can check, if all necessary attributes were written?
edit: google search was negative
To serialize an object means to convert its state to a byte stream so that the byte stream can be reverted back into a copy of the object. A Java object is serializable if its class or any of its superclasses implements either the java. io. Serializable interface or its subinterface, java.
Serialization is performed by method writeObject() of the ObjectOutputStream class. Deserialization is performed by the readObject() of the ObjectInputStream class. These serialization methods are in the java.io package.
The serialized objects are stored in the file "nameStore", like the code specifies. Where that file is created depends on what the default directory is when this code is run.
Write some tests (using Eclipse's built-in JUnit support).
The only way to "look inside" these files is to use ObjectInputStream(FileInputStream(File))
, unless you're a bytecode guru and use a hex editor. If you actually have some testing, there is no need to "look inside" anything.
While this isn't a full fledged editor, Eamonn McManus has written a transcoder which deciphers a serialized blob into a human readable form. http://weblogs.java.net/blog/2007/06/12/disassembling-serialized-java-objects
If binary compatibility and performance are considerations, this would be a good time to look into Externalizable instead of Serializable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With