Here you can find the source of toString(final Serializable o)
public static String toString(final Serializable o) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.Serializable; import javax.xml.bind.DatatypeConverter; public class Main { /** Write the object to a Base64 string. */ public static String toString(final Serializable o) throws IOException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(o);/*from w w w . ja v a 2 s. c om*/ oos.close(); return new String(DatatypeConverter.printBase64Binary(baos.toByteArray())); } }