List of utility methods to do Convert via ByteBuffer
String | toGuidString(UUID uuid) to Guid String byte[] guidBytes = toGuidBytes(uuid); String to = toHex(guidBytes); return to; |
String | toHex(byte[] bytes) Returns hex-digit (lower case) string. StringBuffer buf = new StringBuffer(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { int value = (int) bytes[i] & 0xff; if (value < 0x10) { buf.append("0"); buf.append(Integer.toHexString(value)); return buf.toString(); |
String | toHexBytes(byte[] bytes) Converts the given bytes into a hexadecimal representation. return toHexBytes(bytes, 0, bytes.length);
|
String | toHexString(Number n) to Hex String if (n == null) return "null"; byte[] bytes = new byte[8]; ByteBuffer bytesBuffer = ByteBuffer.wrap(bytes); LongBuffer longBuffer = bytesBuffer.asLongBuffer(); longBuffer.put(0, n.longValue()); StringBuilder sb = new StringBuilder(16); for (int i = 0; i < bytes.length; i++) { ... |
int[] | toInt(byte[] bytes) to Int ByteBuffer byteBuffer = ByteBuffer.wrap(bytes); IntBuffer buffer = byteBuffer.asIntBuffer(); int ret[] = new int[buffer.capacity()]; buffer.get(ret); return ret; |
int | toInt(byte[] data) to Int return ByteBuffer.wrap(data).getInt();
|
int | toInt(byte[] value) Convert the first 4 bytes of an array to a big endian int. if (value == null) { return 0; int val = 0; if (value.length >= 1) { val |= ((value[0] & 0xFF) << 24); if (value.length >= 2) { ... |
int | toInt(final byte lowOrderByte, final byte highOrderByte) to Int return toInt(lowOrderByte, highOrderByte, ByteOrder.LITTLE_ENDIAN);
|
int | toInt(InetAddress address) Converts ipv4 InetAddress to Integer. return ByteBuffer.wrap(address.getAddress()).getInt();
|
int[] | toIntArray(byte[] byteArray) Returns a new integer array using data from the given byte array. IntBuffer intBuffer = ByteBuffer.wrap(byteArray).asIntBuffer(); int[] intArray = new int[intBuffer.limit()]; intBuffer.get(intArray); return intArray; |