List of utility methods to do Byte Array Print
void | printBytes(String comment, byte[] input) print Bytes System.out.println("\n" + comment + ": "); for (int i = 0; i < input.length; i++) { if (i > 0 && i % 32 == 0) System.out.println(""); System.out.print(" " + input[i]); System.out.println(""); |
void | printBytes(String x) print Bytes byte[] xbt = x.getBytes(); for (int i = 0; i < xbt.length; i++) { System.out.print(xbt[i] + ","); |
String | printBytesHexEncoded(final byte[] byteArray) print Bytes Hex Encoded StringBuilder sb = new StringBuilder(byteArray.length * 2); sb.append("["); int i = 0; while (i < byteArray.length) { sb.append(printByteHexEncoded(byteArray[i])); i++; if (i < byteArray.length) { sb.append(", "); ... |
String | printByteSize(long bytes) print Byte Size if (bytes >= 1073741824) { return "" + (Math.round(bytes / 1073741824 * 100) / 100) + "G"; } else if (bytes >= 1048576) { return "" + (Math.round(bytes / 1048576 * 100) / 100) + "M"; } else if (bytes >= 1024) { return "" + (Math.round(bytes / 1024 * 100) / 100) + "K"; } else { return "" + bytes + "B"; ... |
void | printBytesToString(byte[] bytes, String structName) print Bytes To String System.out.println("*************" + structName + "**************"); StringBuilder stringBuilder = new StringBuilder(); for (Byte byteStr : bytes) { String hexByteStr = Integer.toHexString(byteStr.intValue()); if (hexByteStr.length() < 2) { stringBuilder.append("0"); if (hexByteStr.length() > 2) { ... |
String | printByteWithChar(byte[] byteArray) return beautified String of byte array int blockSize = 32; StringBuilder sb = new StringBuilder(); StringBuilder sb1 = new StringBuilder(); for (int i = 0; i < byteArray.length; i++) { if (byteArray[i] > 10) { sb.append(String.format("%02X", byteArray[i])).append(" "); } else { sb.append(" ").append(String.format("%02X", byteArray[i])).append(" "); ... |