Java ObjectOutputStream Create toData(Serializable o)

Here you can find the source of toData(Serializable o)

Description

Write the object to a data.

License

Open Source License

Declaration

public static byte[] toData(Serializable o) throws IOException 

Method Source Code


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

import java.io.*;

public class Main {
    /** Write the object to a data. */
    public static byte[] toData(Serializable o) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(o);/*from w  w w . ja  v  a  2 s.  c  o  m*/
        oos.close();
        return baos.toByteArray();
    }
}

Related

  1. toBlob(Object obj)
  2. toBlob(Serializable object)
  3. toCompressData(Serializable o)
  4. toInputStream(Object object)
  5. toJBytes(Object object)
  6. toSerialized(final Serializable src)