Here you can find the source of slice(ByteBuffer buf, int start, int end)
public static ByteBuffer slice(ByteBuffer buf, int start, int end)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { public static ByteBuffer slice(ByteBuffer buf, int start, int end) { ByteBuffer b = buf.duplicate(); b.position(start);//w w w. ja v a2 s.com b.limit(end); return b.slice(); } }