Java Serializable Serialize serializeObject(Serializable cds)

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

Description

serialize Object

License

Open Source License

Declaration

protected static byte[] serializeObject(Serializable cds) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    protected static byte[] serializeObject(Serializable cds) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte[] data = null;
        try {/*from   ww w  .j a  v a 2 s.  c o  m*/
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            oos.writeObject(cds);
            data = baos.toByteArray();
            oos.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return data;

    }
}

Related

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