Here you can find the source of toString(Serializable o)
Parameter | Description |
---|---|
o | The object to convert |
public static String toString(Serializable o)
//package com.java2s; /*/*w w w .jav a 2 s . com*/ * Copyright (C) 2012 Klaus Reimer <k@ailis.de> * See LICENSE.TXT for licensing information. */ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.Serializable; import javax.xml.bind.DatatypeConverter; public class Main { /** * Converts the specified object into a base64 encoded string. * * @param o * The object to convert * @return The object as a base64 encoded string. */ public static String toString(Serializable o) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); try { ObjectOutputStream objectStream = new ObjectOutputStream(stream); objectStream.writeObject(o); objectStream.close(); return DatatypeConverter.printBase64Binary(stream.toByteArray()); } catch (IOException e) { // Can't happen throw new RuntimeException(e.toString(), e); } } }