Here you can find the source of deserialize(ByteBuffer b)
Parameter | Description |
---|---|
b | Buffer |
public static Object deserialize(ByteBuffer b)
//package com.java2s; //License from project: Apache License import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.nio.ByteBuffer; public class Main { /**//from w w w . j a va 2 s.c o m * Deserialize an object from a ByteBuffer. * @param b Buffer * @return Deserialized object */ public static Object deserialize(ByteBuffer b) { try { //todo: make serialization less clunky! ByteArrayInputStream bais = new ByteArrayInputStream(b.array()); ObjectInputStream ois = new ObjectInputStream(bais); return ois.readObject(); } catch (IOException e) { throw new RuntimeException(e); } catch (ClassNotFoundException ce) { throw new RuntimeException(ce); } } }