Java Object Serialize and Deserialize serializeDeserialize(final Serializable object)

Here you can find the source of serializeDeserialize(final Serializable object)

Description

serialize Deserialize

License

LGPL

Declaration

public static void serializeDeserialize(final Serializable object) throws IOException, ClassNotFoundException 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.io.*;

public class Main {
    public static void serializeDeserialize(final Serializable object) throws IOException, ClassNotFoundException {
        final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(1000);
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
        objectOutputStream.writeObject(object);
        objectOutputStream.close();/*from  www  .j  av  a  2 s .c  om*/

        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
        ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
        Object deserialized = objectInputStream.readObject();
        objectInputStream.close();
    }
}

Related

  1. serializeAndReadObject(File envHome, Object object)
  2. serializeAndRecover(Object o)
  3. serializeAndRecover(Object o)
  4. serializeAndReturnDeserializedObject( T object)
  5. serializeAndUnserialize(T t)
  6. serializeDeserialize(Object object)
  7. serializeDeserialize(T obj)
  8. serializeThenDeserialize(T object)