Here you can find the source of serializeToBase64(Serializable object)
static String serializeToBase64(Serializable object) throws IOException
//package com.java2s; //License from project: Apache License import com.amazonaws.util.Base64; import java.io.*; public class Main { static String serializeToBase64(Serializable object) throws IOException { if (object == null) { return ""; }// w ww.j a v a2s . co m ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream(); ObjectOutputStream objectStream = null; try { objectStream = new ObjectOutputStream(byteArrayStream); objectStream.writeObject(object); return new String(Base64.encode(byteArrayStream.toByteArray())); } finally { if (objectStream != null) objectStream.close(); } } }