Super-simple object serialization in Java

If your software produces costly objects, object serialization may be an option to spare you some bootstrapping time, e.g., when you repeatedly restart your application during development. Apache Commons-Lang offers an implementation of serialization that is an epitome of ease of use: SerializationUtils. The core methods are serialize and deserialize.

Given an object, the actual process of serialization is a one-line statement (split up here):

The same holds for the deserialization process. In these subsequent lines, we assume that the object to be derserialized is an instance of java.lang.String:

A complete executable example can be found on GitHub.

Maven Dependency (a Jar file for download can be found here):

Links

  • [1] SerializationUtils Javadoc
  • [2] Executable example code (Maven project)

Leave a Reply