List of utility methods to do ByteBuffer Get
ByteBuffer | getAsByteBuffer() 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 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(); ... |
String | getAscii(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()); ... |
String | getAsciiString(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; |
Map | getAttrs(Map 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; ... |
long | getBatch(ByteBuffer bb) get Batch return bb.getLong(batchPos);
|
BigDecimal | getBigDecimalFromByteBuffer(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); |
int | getBit(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));
|
String | getBitString(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); ... |