Java Serializable Serialize serializeObject(Serializable serializable)

Here you can find the source of serializeObject(Serializable serializable)

Description

serialize Object

License

Open Source License

Declaration

public static byte[] serializeObject(Serializable serializable) 

Method Source Code

//package com.java2s;
/**/*from   ww  w.j ava  2  s . c  o  m*/
    
 * License: https://github.com/votingsystem/votingsystem/wiki/Licencia
 */

import java.io.*;
import java.util.Base64;

public class Main {
    public static byte[] serializeObject(Serializable serializable) {
        byte[] base64EncodedSerializedObject = null;
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            oos.writeObject(serializable);
            oos.close();
            base64EncodedSerializedObject = Base64.getEncoder().encode(baos.toByteArray());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return base64EncodedSerializedObject;
    }
}

Related

  1. serializeObject(File inFile, Serializable inObject)
  2. serializeObject(Serializable cds)
  3. serializeObject(Serializable o)
  4. serializeObject(Serializable obj, String filename)
  5. serializeObject(Serializable ser)
  6. serializeObjectToFile(File targetFile, Serializable serializable)