19 package org.sleuthkit.autopsy.datamodel;
22 import java.util.Arrays;
23 import java.util.Formatter;
30 final private static char[]
hexArray =
"0123456789ABCDEF".toCharArray();
45 public static String
byteArrayToHex(byte[] array,
int length,
long arrayOffset, Font font) {
59 public static String
byteArrayToHex(byte[] array,
int length,
long arrayOffset) {
63 StringBuilder outputStringBuilder =
new StringBuilder();
66 for (
int curOffset = 0; curOffset < length; curOffset += 16) {
69 if (length - curOffset < 16) {
70 lineLen = length - curOffset;
75 outputStringBuilder.append(String.format(
"0x%08x: ", arrayOffset + curOffset));
79 for (
int i = 0; i < 16; i++) {
81 int v = array[curOffset + i] & 0xFF;
82 outputStringBuilder.append(hexArray[v >>> 4]);
83 outputStringBuilder.append(hexArray[v & 0x0F]);
85 outputStringBuilder.append(
" ");
90 outputStringBuilder.append(
" ");
92 outputStringBuilder.append(
" ");
95 outputStringBuilder.append(
" ");
100 outputStringBuilder.append(
" ");
105 outputStringBuilder.append(
" ");
108 String ascii =
new String(array, curOffset, lineLen, java.nio.charset.StandardCharsets.US_ASCII);
109 for (
int i = 0; i < 16; i++) {
111 if (i < ascii.length()) {
115 if (dec < 32 || dec > 126) {
119 outputStringBuilder.append(c);
122 outputStringBuilder.append(
"\n");
125 return outputStringBuilder.toString();
133 String[] binary =
new String[array.length];
135 for (
int i = 0; i < array.length; i++) {
136 binary[i] = Integer.toBinaryString(array[i]);
138 return Arrays.toString(binary);
static String byteArrayToHex(byte[] array, int length, long arrayOffset)
static String charArrayToByte(char[] array)
static String byteArrayToHex(byte[] array, int length, long arrayOffset, Font font)
final static char[] hexArray