Android Utililty Methods ByteBuffer Create

List of utility methods to do ByteBuffer Create

Description

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

Method

ByteBuffermakeByteBuffer(byte[] arr)
Make a direct NIO ByteBuffer from an array of floats
ByteBuffer bb = ByteBuffer.allocateDirect(arr.length);
bb.order(ByteOrder.nativeOrder());
bb.put(arr);
bb.position(0);
return bb;
ByteBuffermakeByteBuffer(byte[] arr, int length)
make Byte Buffer
ByteBuffer bb = ByteBuffer.allocateDirect(length);
bb.order(ByteOrder.nativeOrder());
bb.put(arr, 0, length);
bb.position(0);
return bb;
ByteBuffermakeByteBuffer(byte[] i_arr)
make Byte Buffer
ByteBuffer bb = ByteBuffer.allocateDirect(i_arr.length);
bb.put(i_arr);
bb.position(0);
return bb;
ByteBuffermakeByteBuffer(int size)
make Byte Buffer
ByteBuffer bb = ByteBuffer.allocateDirect(size);
bb.position(0);
return bb;
ByteBuffermakeByteBuffer(int size)
make Byte Buffer
ByteBuffer bb = ByteBuffer.allocateDirect(size);
bb.position(0);
return bb;
ByteBuffermakeByteBuffer(int size)
make Byte Buffer
ByteBuffer bb = ByteBuffer.allocateDirect(size);
bb.position(0);
return bb;
voidcopyFromStreamToBuffer(ByteBuffer out, DataInputStream in, int length)
Copy the given number of bytes from the given stream and put it at the current position of the given buffer, updating the position in the buffer.
if (out.hasArray()) {
    in.readFully(out.array(), out.position() + out.arrayOffset(),
            length);
    skip(out, length);
} else {
    for (int i = 0; i < length; ++i) {
        out.put(in.readByte());
voidappendSurrogate(ByteBuffer bb, char c)
Append %Uxxxx to the given byte buffer.
bb.put((byte) '%');
bb.put((byte) 'U');
bb.put(HEX_DIGITS[(c >> 12) & 0x0f]);
bb.put(HEX_DIGITS[(c >> 8) & 0x0f]);
bb.put(HEX_DIGITS[(c >> 4) & 0x0f]);
bb.put(HEX_DIGITS[c & 0x0f]);