Code example for ByteBuffer

Methods: get, position, remaining, slice

0
		buffer = b;
	} 
 
	@Override 
	protected int copy(final int p, final byte[] b, final int o, int n) {
		final ByteBuffer s = buffer.slice();
		s.position(p);
		n = Math.min(s.remaining(), n);
		s.get(b, o, n);
		return n;
	} 
 
	@Override 
	void write(PackOutputStream out, long pos, int cnt, MessageDigest digest)
			throws IOException { 
		final ByteBuffer s = buffer.slice();
		s.position((int) (pos - start));
 
		while (0 < cnt) {
			byte[] buf = out.getCopyBuffer();
			int n = Math.min(cnt, buf.length);