This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I was going through process of serilaization in java and done lots of googling also , I just want to know the .ser file that is created after the succesfull serialization process in which we say we have persisted the object state and we try to open it let say in notepad we can able to understand that since it is in encrypted format, if we try to open that .ser file in any hexadecimal editor will we able to see it' contents...? and if not then How we would be able to see it contents ..?
please explain the real time situation where we can prove that serialation is the only solution and it had impacted the performance in terms of efficiency..!!
When you serialize objects using Java's standard serialization mechanism, the objects will be stored in a binary format that you cannot read with a text editor such as Notepad. It is not encrypted; it's just not in text format. You can later deserialize the objects again with some Java code.
Advantages of serialization is that it is easy to do in Java, that it's reasonably efficient, and that it's a compact binary format (compare it to for example XML, which is a very verbose format - an XML file containing the same information will be many times larger than a serialized binary file).
Disadvantages are that the exact file format is not a standard format (you can find the specification here) which means it is very difficult to work with in non-Java environments, and it ties your code very tightly to the content of the serialized file, which means that if you make changes in your source file (for example adding or removing member variables to or from a class), there's a big chance that your new code cannot read old serialized files anymore.
For that last reason, it is often much better to use a standard and extensible file format that is less tightly tied to your source code instead of Java serialization. There are a number of efficient, compact, binary formats that can be used as an alternative to serialization, for example Google Protocol Buffers, BSON, Apache Avro and others. All of those require you to include extra libraries in your project and are not as easy to use as standard Java serialization.
Thanks for the expnation ..is there any editior in which I can open that .ser file (serialized file) and can read the object instance state , although I can do this by de seririalization process also but I want to open .ser file ...??
Saral Saxena wrote:Thanks for the expnation ..is there any editior in which I can open that .ser file (serialized file) and can read the object instance state , although I can do this by de seririalization process also but I want to open .ser file ...??
Why? Unless you want to do this for nefarious reasons, the easiest way by far for you to "read" it is to deserialize the contents and print them out.
Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Ok, but is there a special reason why you need this? Do you have some files with serialized objects that you can't read anymore because you don't have the original classes anymore and now you need to somehow rescue the data?