File extension for a Serialized object

夙愿已清 提交于 2019-11-28 21:22:01

".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 the ser file ??

Possibly, but with great difficulty, and only under certain conditions.

The contents the file is highly dependent o the class that was serialized. Now it is possible to determine what the name of that class is, 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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!