I have an application which make some serialized file at particular location, Now I want to read the value of that serialized file..I am aware of java deserialization process, but I am not aware of the source class which is making this serialized file, Is there any way in java , if suppose i have serialized files with me , i can serialized them and can see the contents of the serialized file..!
You could google for something like java serialization viewer. I'm sure people have written tools to do that. It wouldn't be hard to do.
In fact, what you really want is an object graph viewer. It's a two-step process: 1) Deserialize the file back into Java objects. 2) Display those objects. Step #2 is the same regardless of whether the objects came from serialization or just some arbitrary object graph you happen to pick at some point during your program.
Serialization really has nothing to do with it. The code to parse a serialized file is simply ObjectInputStream.readObject().
please advise me in detail, as in this case I am not aware of the java classes , which are involved in serializing process so while in the way of deserializing I not aware regarding the type casting..so is there any way that I have the serialized file with me I can see it contents only..!! please advise..!!
Saral Saxena wrote:so is there any way that I have the serialized file with me I can see it contents only..!! please advise..!!
Sure, use a hex editor. I assume that's not what you mean though. You want to see something like:
right? Some human-readable form of the objects that have been serialized?
If so, the only way to do that, obviously, is to deserialize the objects. You don't have to use Java's built-in serialization tools to do that, but why wouldn't you? If you don't, then you just have to write the code yourself to do what they're already doing for you.
So learn how to use ObjectInputStream to read the data (the easy part) and then figure out how to represent an arbitrary object graph in a human-readable fashion (the hard part).