Here you can find the source of getObject(ByteBuffer byteBuffer)
public static Object getObject(ByteBuffer byteBuffer) throws ClassNotFoundException, IOException
//package com.java2s; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.nio.ByteBuffer; public class Main { public static Object getObject(byte[] bytes) throws IOException, ClassNotFoundException { ByteArrayInputStream bi = new ByteArrayInputStream(bytes); ObjectInputStream oi = new ObjectInputStream(bi); Object obj = oi.readObject(); bi.close();//ww w.jav a2 s . c o m oi.close(); return obj; } public static Object getObject(ByteBuffer byteBuffer) throws ClassNotFoundException, IOException { InputStream input = new ByteArrayInputStream(byteBuffer.array()); ObjectInputStream oi = new ObjectInputStream(input); Object obj = oi.readObject(); input.close(); oi.close(); byteBuffer.clear(); return obj; } }