Java Utililty Methods Byte Array Convert To

List of utility methods to do Byte Array Convert To

Description

The list of methods to do Byte Array Convert To are organized into topic(s).

Method

Stringbytes2Bin(byte[] bytes)
bytes Bin
StringBuilder sb = new StringBuilder();
for (byte b : bytes) {
    for (int i = 0; i < 8; i++) {
        sb.append(bitAt(b, i));
return sb.toString();
booleanbytes2boolean(final byte[] b)
bytesboolean
if (b == null || b.length > 1) {
    throw new IllegalArgumentException("Array is wrong size");
return b[0] != (byte) 0;
byte[][]bytes2byteArray(byte[] bytes, byte separator)
Splits the array of bytes into array of arrays of bytes on byte separator
return bytes2byteArray(bytes, bytes.length, separator);
char[]bytes2Chars(byte[] bytes)
bytes Chars
char[] result = new char[bytes.length / 2];
for (int i = 0; i < result.length; i++) {
    result[i] = (char) (((int) bytes[i * 2]) * 256 + (int) bytes[i * 2 + 1]);
return result;
Stringbytes2humanReadable(long bytes)
byteshuman Readable
String humanReadable = "";
long remaining = bytes;
int prefixIndex = 0;
long reminder;
do {
    reminder = remaining % 1024;
    remaining = remaining / 1024;
    humanReadable = reminder + MEMORY_SIZE_PREFIXES[prefixIndex++] + "B"
...
intbytes2intLE(byte[] bytes, int offset, int len)
bytesint LE
int sum = 0;
for (int i = 0; i < len; i++) {
    byte b = bytes[offset + len - i - 1];
    sum = sum + ((b & 0xff) << (i * 8));
return sum;
Stringbytes2ip(byte[] bytes)
bytesip
return new StringBuffer().append(bytes[0] & 0xFF).append('.').append(bytes[1] & 0xFF).append('.')
        .append(bytes[2] & 0xFF).append('.').append(bytes[3] & 0xFF).toString();
Stringbytes2IPV4(byte[] addr, int offset)
bytes IPV
String hostName = "" + (addr[offset] & 0xFF);
for (int i = offset + 1; i < offset + 4; i++) {
    hostName += "." + (addr[i] & 0xFF);
return hostName;
byte[]bytes2nibbles(byte[] bytes)
bytesnibbles
byte[] nibb = new byte[bytes.length * 2];
for (int i = 0; i < bytes.length; i++) {
    nibb[i * 2] = (byte) (bytes[i] >> 4);
    nibb[i * 2 + 1] = (byte) (bytes[i] & 0x0F);
return nibb;
Stringbytes2unique(byte[] daten, int offset)
bytesunique
if (daten.length - offset < 16) {
    byte[] temp = new byte[16];
    System.arraycopy(daten, offset, temp, 0, daten.length - offset);
    daten = temp;
char[] chars = new char[36];
chars[8] = chars[13] = chars[18] = chars[23] = '-';
chars[0] = digits[(daten[offset + 3] >> 4) & 0x0F];
...