Java Object Serialize serialize(Object object)

Here you can find the source of serialize(Object object)

Description

Serialize the specified object

License

Open Source License

Parameter

Parameter Description
object - object to serialize

Exception

Parameter Description
IOException - if there is an error with serialization

Return

byte[] - the serialized object

Declaration

static public byte[] serialize(Object object) throws IOException 

Method Source Code

//package com.java2s;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

import java.io.ObjectOutputStream;

public class Main {
    /**/*from w  w  w  .  j  a  va2s.c o  m*/
     * Serialize the specified object
     *
     * @param object - object to serialize
     * @return byte[] - the serialized object
     * @throws IOException - if there is an error with serialization
     */
    static public byte[] serialize(Object object) throws IOException {

        ByteArrayOutputStream bstream = new ByteArrayOutputStream();
        ObjectOutputStream ostream = new ObjectOutputStream(bstream);
        ostream.writeObject(object);

        return bstream.toByteArray();
    }
}

Related

  1. serialize(Object object)
  2. serialize(Object object)
  3. serialize(Object object)
  4. serialize(Object object)
  5. serialize(Object object)
  6. serialize(Object object)
  7. serialize(Object object)
  8. serialize(Object object)
  9. serialize(Object object)