Here you can find the source of encode(Serializable s)
public static String encode(Serializable s)
//package com.java2s; //License from project: Apache License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Base64; public class Main { public static String encode(Serializable s) { try (ByteArrayOutputStream of = new ByteArrayOutputStream(); ObjectOutputStream so = new ObjectOutputStream(of)) { so.writeObject(s);/*from ww w.jav a2s. c o m*/ so.flush(); return Base64.getEncoder().encodeToString(of.toByteArray()); } catch (IOException e) { throw new UnsupportedOperationException(e); } } }