Java Utililty Methods ByteBuffer Get

List of utility methods to do ByteBuffer Get

Description

The list of methods to do ByteBuffer Get are organized into topic(s).

Method

double[]getDoubleArray(ByteBuffer buffer, int numDoubles)
get Double Array
double[] result = new double[numDoubles];
for (int i = 0; i < numDoubles; i++) {
    result[i] = buffer.getDouble();
return result;
doublegetDoubleFromByteBuffer(ByteBuffer data)
double from ByteBuffer
return getDoubleFromBytes(data.array());
ByteBuffergetEmptyByteBuffer()
empty ByteBuffer
byte[] data = {};
return ByteBuffer.wrap(data);
byte[]getFixedBytes(ByteBuffer buffer, int length)
get Fixed Bytes
byte[] result = new byte[length];
buffer.get(result);
return result;
float[]getFloat(ByteBuffer b, int n)
get Float
float f[] = new float[n];
for (int k = 0; k < f.length; k++) {
    f[k] = b.getFloat();
return f;
floatgetFloat(ByteBuffer buffer)
get Float
assert (buffer.capacity() - buffer.position() >= 4);
byte[] data = new byte[4];
data[3] = buffer.get();
data[2] = buffer.get();
data[1] = buffer.get();
data[0] = buffer.get();
return Float.intBitsToFloat(((data[0] << 24) & 0xff000000) | ((data[1] << 16) & 0x00ff0000)
        | ((data[2] << 8) & 0x0000ff00) | (data[3] & 0x000000ff));
...
floatgetFloat(ByteBuffer floatCalculator, byte[] bytes)
Calculates the corresponding float given 4 sequential bytes.
floatCalculator.clear();
floatCalculator.put(bytes);
floatCalculator.position(0);
return floatCalculator.getFloat();
bytegetFromBack(ByteBuffer bb)
get From Back
byte ret = bb.get(bb.limit() - 1);
bb.limit(bb.limit() - 1);
return ret;
byte[]getHashBytes(ByteBuffer bb)
Returns a byte[] from the info_hash ByteBuffer for simplicity.
bb.position(0);
byte[] array = new byte[20];
bb.get(array);
return array;
float[]getHSBfromRGB(final ByteBuffer pixels, final float[] result, int pixelSize)
get HS Bfrom RGB
int idx = 0;
for (int i = result.length / 3; --i >= 0;) {
    float hue;
    final float saturation;
    final float brightness;
    final int r = pixels.get() & 0xFF;
    final int g = pixels.get() & 0xFF;
    final int b = pixels.get() & 0xFF;
...