Here you can find the source of serializeObject(Serializable o)
public static String serializeObject(Serializable o) throws IOException
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Base64; public class Main { /** Write the object to a Base64 string. */ public static String serializeObject(Serializable o) throws IOException { if (o == null) return null; ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(o);//from w w w .ja v a 2 s . com oos.close(); return Base64.getEncoder().encodeToString(baos.toByteArray()); } }