Java ByteBuffer Size calcSize(ByteBuffer buffer)

Here you can find the source of calcSize(ByteBuffer buffer)

Description

calc Size

License

Open Source License

Declaration

public static long calcSize(ByteBuffer buffer) 

Method Source Code


//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;
    }
}

Related

  1. adaptImageSize(final BufferedImage img, final int width, final int height)
  2. addToStringBuilder(StringBuilder sb, ByteBuffer buffer, int size)
  3. check(ByteBuffer buffer, int size)
  4. checkBounds(BufferedImage image, int xStart, int yStart, int width, int height)
  5. checkBufferSize(ByteBuffer buf, int elementSize)
  6. chooseAppropriateTileSize(BufferedImage image)