Java provides (binary) serialization of objects using ObjectOutputStream (and ObjectInputStream). You can simply writeObject () to the stream and readObject () at the other end. All you have to do for this is to implement the Serializable interface.
But instead of doing it manually, you may be interested in taking it one level and using the method's remote method call. With RMI, you can call methods on objects that live in another JVM, and all serialization and networking takes place under the hood.
And for completeness, there is also XML serialization if you cannot use the binary format. This XML format is very common (read: verbose and ugly), but there are some popular libraries (like XStream) that create alternative XML serializations.
Prashant gautam
source share