I have this simple application with a couple of classes which are all related. There’s one, the main one, for which there is only one instance of. I need to save save and load that using a text stream.
My instructor requirement is BufferedReader to load the stream and PrintWriter to save it. But is this even possible? To persist a data object/class with a text stream?
I know how to do it with an object, using serialization. But I don’t see how am I supposed to do it using text streams.
Suggestions?
You need to define your own, simple, serialization protocol. Writing writes out the fields that need to be saved, reading reads them back in.