I have a large amount of data stored in a Collection.
I would like to save this data to a file. Is it a good idea to use Serialization?
Or should I use a custom format to save the data, or save it as XML for example?
(The elements in the Collection are custom classes. Do I need to implement a method that serializes the objects?)
I have a large amount of data stored in a Collection . I would
Share
I would not write a serialized class to disk. Once the JVM or any libraries change it might be useless. This means a file created on one system may not work on another!
Instead, I’d write a text version of the data. If your collection includes other collections or classes, I’d use XML as it handles nesting well. If the data is simple I’d probably just write a comma-sep file with a header line including a version number and a description of the data set, a line telling the column names, the data lines, and an EOF line.