public static Object objectFromByteBuffer(byte[] buffer) throws IOException, ClassNotFoundException {
  if (buffer == null)   return null;
  OptimizedByteArrayInputStream inStream=new OptimizedByteArrayInputStream(buffer);
  ObjectInputStream in=new ObjectInputStream(inStream);
  Object retval=in.readObject();
  in.close();
  return retval;
}

public static Object objectFromByteBuffer ( byte [ ] buffer ) throws IOException , ClassNotFoundException { if ( buffer == null ) return null ; OptimizedByteArrayInputStream inStream = new OptimizedByteArrayInputStream ( buffer ) ; ObjectInputStream in = new ObjectInputStream ( inStream ) ; Object retval = in . readObject ( ) ; in . close ( ) ; return retval ; }
creates an object from a byte buffer .
