Here you can find the source of serialize(T object)
Parameter | Description |
---|---|
object | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static <T extends Serializable> byte[] serialize(T object) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { /**//from ww w . j a va2 s .c om * @param object * @return * @throws IOException */ public static <T extends Serializable> byte[] serialize(T object) throws IOException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(object); oos.close(); return baos.toByteArray(); } }