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

ByteBuffergetAsByteBuffer()
get As Byte Buffer
try {
    Charset charset = Charset.forName("ISO-8859-1");
    CharsetEncoder encoder = charset.newEncoder();
    ByteBuffer buf = encoder.encode(CharBuffer.wrap(testMail.toCharArray()));
    return buf;
} catch (Exception e) {
    throw new RuntimeException(e.toString());
byte[]getAsBytes(List buffers)
Copies the contents of the buffers into a single byte[]
int size = 0;
for (ByteBuffer buffer : buffers) {
    size += buffer.remaining();
byte[] arr = new byte[size];
int offset = 0;
for (ByteBuffer buffer : buffers) {
    int len = buffer.remaining();
...
StringgetAscii(ByteBuffer bytes)
get Ascii
StringBuilder builder = new StringBuilder();
if (bytes.remaining() < 2)
    throw new IOException("too few bytes specified for string value!");
int numBytes = getUnsignedShort(bytes);
if (bytes.remaining() < numBytes)
    throw new IOException("too few bytes specified for string value!");
for (int i = 0; i < numBytes; i++)
    builder.append((char) bytes.get());
...
StringgetAsciiString(ByteBuffer buffer)
get Ascii String
return getString(buffer, "US-ASCII");
int[]getAsIntArray(ByteBuffer yuv, int size)
get As Int Array
byte[] b = new byte[size];
int[] result = new int[size];
yuv.get(b);
for (int i = 0; i < b.length; i++) {
    result[i] = b[i] & 0xff;
return result;
MapgetAttrs(Map fields)
get Attrs
if (fields == null) {
    return new HashMap<String, byte[]>();
HashMap<String, byte[]> tempMap = new HashMap<String, byte[]>();
for (CharSequence u : fields.keySet()) {
    tempMap.put(u.toString(), fields.get(u).array());
return tempMap;
...
longgetBatch(ByteBuffer bb)
get Batch
return bb.getLong(batchPos);
BigDecimalgetBigDecimalFromByteBuffer(ByteBuffer bytebuf, int start, int length, int scale)
get Big Decimal From Byte Buffer
byte[] value = new byte[length];
bytebuf.get(value);
BigInteger unscaledValue = new BigInteger(value);
return new BigDecimal(unscaledValue, scale);
intgetBit(ByteBuffer in, int pos)
Get a bit from the input ByteBuffer Returns the bit at bit position pos in ByteBuffer in.
return in.get(pos >> 3) & (1 << (pos % NBITS_PER_BYTE));
StringgetBitString(java.nio.ByteBuffer buffer, int lenBits)
get Bit String
String s = "";
int len = (int) Math.ceil(lenBits / (double) Byte.SIZE);
if (null != buffer && buffer.remaining() >= len) {
    byte[] dest = new byte[len];
    buffer.get(dest, 0, len);
    char[] bits = new char[lenBits];
    for (int i = 0; i < lenBits; i++) {
        int mask = 0x1 << (Byte.SIZE - (i % Byte.SIZE) - 1);
...