Here you can find the source of slice(ByteBuffer data)
public static ByteBuffer slice(ByteBuffer data)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; public class Main { public static ByteBuffer slice(ByteBuffer data) { if (data.hasRemaining()) { byte[] slice = new byte[data.remaining()]; data.get(slice, 0, data.remaining()); return ByteBuffer.wrap(slice); }/*from ww w . j av a 2s .c om*/ return null; } }