Here you can find the source of calcSize(ByteBuffer buffer)
public static long calcSize(ByteBuffer buffer)
//package com.java2s; /* Copyright 2004 - 2007 Kasper Nielsen <kasper@codehaus.org> Licensed under * the Apache 2.0 License, see http://coconut.codehaus.org/license. *///ww w . j a v a 2s.co m import java.nio.ByteBuffer; public class Main { public static long calcSize(ByteBuffer buffer) { return buffer.limit() - buffer.position(); } public static long calcSize(ByteBuffer[] buffers) { return calcSize(buffers, 0, buffers.length); } public static long calcSize(ByteBuffer[] buffers, int offset, int length) { long totalLength = 0; for (int i = 0; i < length; i++) { totalLength += calcSize(buffers[i + offset]); } return totalLength; } }