1 45 46 47 package org.openejb.spi; 48 49 50 import java.io.ByteArrayInputStream ; 51 import java.io.ByteArrayOutputStream ; 52 import java.io.IOException ; 53 import java.io.ObjectInputStream ; 54 import java.io.ObjectOutputStream ; 55 56 57 public class Serializer { 58 59 60 public static Object deserialize(byte [] bytes) 61 throws IOException , ClassNotFoundException { 62 ByteArrayInputStream bais = new ByteArrayInputStream (bytes); 63 ObjectInputStream ois = new ObjectInputStream (bais); 64 return ois.readObject(); 65 } 66 public static byte [] serialize(Object object) throws IOException { 67 ByteArrayOutputStream baos = new ByteArrayOutputStream (); 68 ObjectOutputStream oos = new ObjectOutputStream (baos); 69 oos.writeObject(object); 70 oos.flush(); 71 return baos.toByteArray(); 72 } 73 74 } 75 | Popular Tags |