public static Object deserialize ( byte [ ] bytes ) { if ( bytes == null ) { return null ; } try { ObjectInputStream ois = new ObjectInputStream ( new ByteArrayInputStream ( bytes ) ) ; return ois . readObject ( ) ; } catch ( IOException ex ) { throw new IllegalArgumentException ( "Failed to deserialize object" , ex ) ; } catch ( ClassNotFoundException ex ) { throw new IllegalStateException ( "Failed to deserialize object type" , ex ) ; } }
Deserialize the byte array into an object .