Java Object Serialize serialized(final Object item)

Here you can find the source of serialized(final Object item)

Description

serialized

License

Open Source License

Declaration

public static byte[] serialized(final Object item) throws IOException 

Method Source Code


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

import java.io.*;

public class Main {
    public static byte[] serialized(final Object item) throws IOException {
        if (item == null)
            throw new NullPointerException();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = null;
        try {/*from   www .  ja  va2  s  .  c  o  m*/
            oos = new ObjectOutputStream(baos);
            oos.writeObject(item);
            oos.flush();
        } catch (IOException e) {
            throw e;
        } finally {
            try {
                if (oos != null)
                    oos.close();
            } catch (IOException e) {
                // eat it.
            }
        }
        return baos.toByteArray();
    }
}

Related

  1. serialize(T object)
  2. serialize(T t)
  3. serialize(T t, String filename)
  4. serialize(T t, String path)
  5. serialize(T toSerialize)
  6. serialized(Object o)
  7. serialized(Serializable original)
  8. serializeObject(final Serializable obj)
  9. serializeObject(Object data)