Java XML Data Type Converter toString(final Serializable o)

Here you can find the source of toString(final Serializable o)

Description

Write the object to a Base64 string.

License

Open Source License

Declaration

public static String toString(final Serializable o) throws IOException 

Method Source Code

//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()));
    }
}

Related

  1. stringToData(String data)
  2. toBinaryKeyId(String keyId)
  3. toPlaintext(String encryptedText, String password)
  4. toRoboCommand(int command)
  5. toString(byte[] edid)
  6. toString(Serializable o)
  7. toTime(String st)
  8. unserializeURLSafe(String string)
  9. writeKey(Writer writer, PublicKey publicKey)