Java Utililty Methods Byte Array Print

List of utility methods to do Byte Array Print

Description

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

Method

StringprintByteArrayToHex(byte[] byteArray, int length)
print Byte Array To Hex
StringBuffer buffer = new StringBuffer();
for (int z = 0; z < length; z++) {
    buffer.append(Integer.toHexString(byteArray[z]));
return buffer.toString();
StringprintByteHexEncoded(byte b)
print Byte Hex Encoded
return String.format("0x%02x", b & 0xff);
voidprintBytes(byte[] ba)
print Bytes
printBytes(ba, false);
StringprintBytes(byte[] buffer, int start, int length)
print Bytes
StringBuilder sb = new StringBuilder(length - start);
for (int i = start; i < start + length; i++) {
    sb.append(String.format("%%%02x", buffer[i]));
return sb.toString();
voidprintBytes(byte[] bytes)
print Bytes
StringBuilder sb = new StringBuilder();
for (byte b : bytes) {
    String byteString = Integer.toHexString(b & 0x000000FF);
    byteString = byteString.length() == 1 ? "0" + byteString : byteString;
    sb.append(byteString);
System.out.println(sb.toString());
StringprintBytes(byte[] bytes)
print Bytes
return printBytes(bytes, 0, bytes.length);
voidprintBytes(byte[] bytes)
print Bytes
printBytes(bytes, 0, bytes.length);
voidprintBytes(byte[] bytes)
print Bytes
if (bytes == null || bytes.length <= 0) {
    System.out.println("Empty byte array.");
    return;
StringBuilder sb = new StringBuilder();
sb.append("Total length:");
sb.append(bytes.length);
sb.append(",[");
...
voidprintBytes(byte[] bytes, int offset)
print Bytes
for (int i = offset; i < bytes.length; i++) {
    System.out.print("(" + i + "):" + bytes[i]);
System.out.println();
StringprintBytes(byte[] data)
print Bytes
StringBuffer sb = new StringBuffer();
sb.append("[");
for (int i = 0; i < data.length; i++) {
    String hex = Integer.toHexString(data[i]);
    if (hex.length() == 1)
        hex = "0" + hex;
    else
        hex = hex.substring(hex.length() - 2);
...