What file extension would be most suitable when saving a Serializable
object to disk?
FileOutputStream fos = null; ObjectOutputStream out = null; try { fos = new FileOutputStream(filename); out = new ObjectOutputStream(fos); out.writeObject(mySerializableObject); } catch (IOException ex) { ex.printStackTrace(); } finally { IOUtils.closeQuietly(out); }
A SER file contains a series of frame captures saved in the Lucam video format, which is used to store astronomical captures, such as planets, the sun, and the moon. It stores data about image frames and includes metadata, such as timestamps, exposure time, instrument, telescope, and observer.
Serialization is the process of converting an object into a stream of bytes to store the object or transmit it to memory, a database, or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed. The reverse process is called deserialization.
The serialized objects are JVM independent and can be re-serialized by any JVM. In this case the "in memory" java objects state are converted into a byte stream. This type of the file can not be understood by the user. It is a special types of object i.e. reused by the JVM (Java Virtual Machine).
".ser" is a reasonable choice for the file suffix - http://www.file-extensions.org/ser-file-extension
However, you could argue that it make little difference what suffix you use ... provided that is doesn't clash other commonly used application suffixes.
A Java serialized object file can only be read (in the normal way) by a Java application that has the relevant classes on its classpath. A one-size-fits-all ".ser" suffix provides no clues as to what those classes might be and where an application launch framework should find them. So you won't be able to set up a Windows-style file association to provide double-click application launching.
Is there a way i can view or edit a ".ser" file ??
Possibly, but with great difficulty, and only under certain conditions.
The contents the file will be highly dependent on the class that was serialized. Now it is possible to determine the name of that class, and (in some cases) the names and types of the serialized fields. However if the class uses custom serialization / externalization, the representation will be an opaque blob of binary data with no clues in the file as to how to decode it. The opaque blob problem is fairly common because many important classes in the Java SE class library use custom serialization ... for efficiency ... and so do many application classes.
The other possible approach is to find the .class files for all of the classes mentioned in the .ser file, deserialize to objects, and use reflection to access the fields of the deserialised objects. You could even tweak them and reserialize them. However, if you don't have the right versions of all of the .class files, this is a non-starter.
Finally, editing a ".ser" file using a binary editor is technically possible, but would be dangerous. The serialization format is not designed to support this.
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