Here you can find the source of deserialize(byte[] byteArray)
public static Serializable deserialize(byte[] byteArray) throws IOException, ClassNotFoundException
//package com.java2s; //License from project: Apache License import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.Serializable; public class Main { public static Serializable deserialize(byte[] byteArray) throws IOException, ClassNotFoundException { return deserialize(byteArray, Thread.currentThread().getContextClassLoader()); }// ww w .j a v a2 s. com public static Serializable deserialize(byte[] byteArray, ClassLoader classLoader) throws IOException, ClassNotFoundException { ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(classLoader); ByteArrayInputStream byteArrayIn = new ByteArrayInputStream(byteArray); ObjectInput objectIn = null; Serializable result; try { objectIn = new ObjectInputStream(byteArrayIn); result = (Serializable) objectIn.readObject(); } finally { try { byteArrayIn.close(); } catch (IOException ex) { // ignore close exception } try { if (objectIn != null) { objectIn.close(); } } catch (IOException ex) { // ignore close exception } Thread.currentThread().setContextClassLoader(originalClassLoader); } return result; } }