public static Object deserializeFromByteArray(byte[] bytes) throws Exception { ByteArrayInputStream bis = new ByteArrayInputStream(bytes); ObjectInput in = null; try { in = new ObjectInputStream(bis); Object o = in.readObject(); return o; } finally { bis.close(); in.close(); } } }