Java tutorial
//package com.java2s; import java.io.ByteArrayInputStream; import java.io.ObjectInputStream; public class Main { @SuppressWarnings("unchecked") public static <T> T deserializeFromByteArray(byte[] bytes) { if (bytes == null) { return null; } ByteArrayInputStream bais = new ByteArrayInputStream(bytes); T object = null; try { ObjectInputStream ois = new ObjectInputStream(bais); object = (T) ois.readObject(); } catch (Exception e) { e.printStackTrace(); return null; } return object; } }