The list of methods to do Dump Byte Array are organized into topic(s).
void
dump(byte[] buffer, int start, int size, PrintStream out) Prints hex dump of part of byte array to specified stream
StringBuffer sb = new StringBuffer();
int pos = 0;
for (int i = 0; i < size / 16; i++) {
_dump(buffer, start + pos, 16, out);
pos += 16;
out.println();
_dump(buffer, start + pos, size - pos, out);
...
void
dump(final byte[] b, final PrintStream out) dump
for (int i = 0; i < b.length; ++i) {
if (i % 16 == 0) {
out.print(Integer.toHexString(i & 0xFFFF | 0x10000).substring(1, 5) + " - ");
out.print(Integer.toHexString(b[i] & 0xFF | 0x100).substring(1, 3) + ' ');
if (i % 16 == 15 || i == b.length - 1) {
int j;
for (j = 16 - i % 16; j > 1; --j) {
...
String
dumpByteArray(byte[] byteArray) creates a nice hex-dump of the byte array
if (byteArray == null) {
return "null";
return dumpInputStream(new ByteArrayInputStream(byteArray));
String
dumpByteArray(byte[] bytes) dump Byte Array
StringBuilder sb = new StringBuilder();
for (int i = 0; i < bytes.length; i++) {
byte b = bytes[i];
int iVal = b & 0xFF;
int byteN = Integer.parseInt(Integer.toBinaryString(iVal));
sb.append(String.format("%102ドルd: %208ドルd %31ドルc %3$d\n", i, byteN, iVal));
return sb.toString();
...
void
dumpBytes(PrintStream printStream, byte bytes[]) dump Bytes
for (int i = 0; i < bytes.length; i++) {
if (i % 16 == 0)
printStream.printf("%106ドルX:", i);
printStream.print(' ');
if (bytes[i] < 32 || bytes[i] >= 127)
printStream.print(' ');
else
printStream.print((char) bytes[i]);
...
void
dumpBytesToFile(byte[] bytes, String outputFile) dump Bytes To File
try {
BufferedWriter bw = new BufferedWriter(new FileWriter(outputFile));
for (int i = 0; i < bytes.length; ++i) {
bw.write(getByteAsAscii(bytes[i]));
if ((i + 1) % 16 == 0) {
bw.write("\n");
bw.close();
} catch (IOException e) {
e.printStackTrace();