Here you can find the source of getObject(ByteBuffer byteBuffer)
public static Object getObject(ByteBuffer byteBuffer) throws IOException, ClassNotFoundException
//package com.java2s; /*/*from ww w.ja v a2 s.com*/ * Copyright (c) 2007, 2011-2013 Eike Stepper (Berlin, Germany) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Eike Stepper - initial API and implementation */ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.nio.ByteBuffer; public class Main { private static final byte TRUE = (byte) 1; public static Object getObject(ByteBuffer byteBuffer) throws IOException, ClassNotFoundException { boolean nonNull = byteBuffer.get() == TRUE; if (nonNull) { byte[] array = getByteArray(byteBuffer); ByteArrayInputStream bais = new ByteArrayInputStream(array); ObjectInputStream stream = new ObjectInputStream(bais); return stream.readObject(); } return null; } public static byte[] getByteArray(ByteBuffer byteBuffer) { short length = byteBuffer.getShort(); byte[] array = new byte[length]; if (length != 0) { byteBuffer.get(array); } return array; } }