this is my first post here, but I'm really needing help on this one because I'm just starting to learn about Serialization/Deserialization in Java:
I have a String that looks something like this:
String str = "ExampleClass[id=123,date=2009-07-12,state=OPEN]";
My question is: can I deserialize this so I can access the information inside this String?
I've only seen examples where they use ObjectOutputStream
and the method .writeObject()
to first create a file and then later read from it.
I also have a class that looks like this:
public class ExampleClass implements Serializable {
protected String id;
protected Date startDate;
protected String state;
//other code...
public String toString(){
return "ExampleClass[id="+id+",date="+startDate+",status="state"]";
}
}
Maybe I haven't fully understood the concept of deserialization yet, but hopefully I could get an input here and find out if what I'm trying to do won't work or makes no sense. Thanks in advance!