This content has been marked as final. Show 4 replies
Its not serialization vs. I/O, because serialization makes use of java.io to actually store its data to a destination.
Serialization is useful because it provides a very easy way to persist an object graph if you don't care too much about the storage format.
Of course you can do the same thing manually, but you'd be writing a lot more code for storing and loading the data. You'd have more control over the format, but that control comes at a price.
Neha_Khands wrote:There are many, many ways. Here are some of them:
Can you please tell me what are the different ways to save an object's state other than using serialization?
- You can use XMLEncoder to write XML in a generic format
- You can use JAXB to write out a custom, specific XML format
- You can use Serialization to write a generic binary format (which you can influence by implement the Externalizable interface, making that a partially custom format).
- You can write out your data manually in a custom binary format using a DataOutputStream
- You can write out your data manually in a custom text format using Writers
It's always a trade-off between:
- amount of code to write
- ease of manipulation of the data
- human readability of the output
- size of the output file