List of utility methods to do Convert via ByteBuffer
void | longToBytes(long x, byte[] dest, int offset) long To Bytes bufferLock.lock(); try { longbuffer.clear(); longbuffer.putLong(0, x); System.arraycopy(longbuffer.array(), 0, dest, offset, Long.BYTES); } finally { bufferLock.unlock(); |
byte[] | longToBytesNoLeadZeroes(long val) Converts a long value into a byte array. byte[] data = ByteBuffer.allocate(8).putLong(val).array(); return stripLeadingZeroes(data); |
byte[] | longToFourBytesFlip(long l) long To Four Bytes Flip ByteBuffer buffer = ByteBuffer.allocate(Byte.BYTES * 8);
buffer.putLong(l);
return Arrays.copyOfRange(buffer.array(), 4, 8);
|
int | longToHeight(long x) long To Height ByteBuffer buffer = ByteBuffer.allocate(8);
buffer.order(ByteOrder.LITTLE_ENDIAN);
buffer.putLong(0, x);
return buffer.getInt(4);
|
String | longToIPv4(Long ip) long To I Pv ByteBuffer buffer = ByteBuffer.allocate(Integer.SIZE / 8); buffer.putInt(ip.intValue()); try { InetAddress addr = InetAddress.getByAddress(buffer.array()); return addr.getHostAddress(); } catch (UnknownHostException e) { return null; |
byte[] | longToLE(long lVal) Pack integer value to Little Endian. ByteBuffer bb = ByteBuffer.allocate(Integer.SIZE / 8);
bb.order(ByteOrder.LITTLE_ENDIAN);
bb.putLong(lVal);
return bb.array();
|
short[] | longToShorts2(long value) long To Shorts short[] shorts = new short[4]; ByteBuffer b = ByteBuffer.allocate(8); b.putLong(value); b.rewind(); shorts[0] = b.getShort(); shorts[1] = b.getShort(); shorts[2] = b.getShort(); shorts[3] = b.getShort(); ... |
byte[] | shortToByteArray(short inShort) short To Byte Array byte[] bArray = new byte[2]; ByteBuffer bBuffer = ByteBuffer.wrap(bArray); ShortBuffer lBuffer = bBuffer.asShortBuffer(); lBuffer.put(inShort); return bArray; |
byte[] | shortToBytes(short s) short To Bytes ByteBuffer b = ByteBuffer.allocate(2);
b.putShort(s);
return b.array();
|
String[] | stringsFromBinary(final byte[] binary) Utility to convert bytes to a String final ByteBuffer buf = ByteBuffer.wrap(binary); final int count = buf.getInt(); final String[] result = new String[count]; for (int i = 0; i < count; i++) { final int size = buf.getInt(); final byte[] strBytes = new byte[size]; buf.get(strBytes); result[i] = new String(strBytes, GEOWAVE_CHAR_SET); ... |