List of utility methods to do Byte Array Convert To
String | bytesToIpString(byte[] bytes) bytes To Ip String return new StringBuffer().append(bytes[0] & 0xFF).append('.').append(bytes[1] & 0xFF).append('.') .append(bytes[2] & 0xFF).append('.').append(bytes[3] & 0xFF).toString(); |
long | bytesToLength(final byte bytes[]) Takes an array of 4 bytes and converts it to a long, the way the ID3 tag expects it to be converted, which is to say that only 7 bits of each byte is used, giving a max value of 2^28. return bytes[0] << 21 | bytes[1] << 14 | bytes[2] << 7 | bytes[3];
|
String | bytesToMac(byte[] bytes) bytes To Mac StringBuffer sb = new StringBuffer(); for (int i = 0; i < bytes.length; i++) { String s = Integer.toHexString(0xFF & bytes[i]).toUpperCase(); if (i > 0) { sb.append(":"); if (s.length() == 1) { sb.append("0"); ... |
String | bytesToMac(final byte[] bytes) bytes To Mac final StringBuilder sb = new StringBuilder((bytes.length * 3) - 1); for (final byte b : bytes) { if (sb.length() > 0) sb.append(":"); sb.append(Character.forDigit((b >>> 4) & 0xF, 16)); sb.append(Character.forDigit((b & 0xF), 16)); return sb.toString(); ... |
long | bytesToNumber(byte[] buffer, int start, int length) Reconstructs a number that is represented by more than one byte in a network packet in big-endian order. long result = 0; for (int index = start; index < start + length; index++) { result = (result << 8) + unsign(buffer[index]); return result; |
String | bytesToPdu(byte[] bytes) bytes To Pdu StringBuffer sb = new StringBuffer(); for (int i = 0; i < bytes.length; i++) { sb.append(byteToPdu(bytes[i] & 0xFF)); return sb.toString(); |
long | bytesToSectors(long bytes) bytes To Sectors return divideAndRoundUp(bytes, DISKLIB_SECTOR_SIZE);
|
int | bytesToSignedInt(byte bb1, byte bb2) bytes To Signed Int return ((bb1 << 8) + (bb2 & 0xff));
|
int | bytesToStore(int bits) The number of bytes required to store a number of bits. return (bits / 8) + ((bits % 8 != 0) ? 1 : 0);
|
String | bytesToStringAscii(byte[] bytes) bytes To String Ascii char[] buffer = new char[bytes.length]; for (int i = 0; i < buffer.length; i++) { buffer[i] = (char) bytes[i]; return new String(buffer); |