Java Utililty Methods Hex Dump

List of utility methods to do Hex Dump

  1. HOME
  2. Java
  3. H
  4. Hex Dump

Description

The list of methods to do Hex Dump are organized into topic(s).

Method

void hexdump(byte[] bytes, OutputStream out)
hexdump
hexdump(bytes, new PrintStream(out));
String hexDump(byte[] data)
Dumps binary data, presending raw bytes and their character equivalents.
if (data == null) {
 return NULL;
} else {
 StringWriter w = new StringWriter();
 hexDump(0, new PrintWriter(w), data, 0, data.length);
 return w.toString();
void hexDump(InputStream is, OutputStream os)
Writes a hex dump representation of input data to the output stream.
int offset = 0;
ByteArrayOutputStream hexStream;
ByteArrayOutputStream asciiStream;
while (true) {
 hexStream = new ByteArrayOutputStream();
 asciiStream = new ByteArrayOutputStream();
 int count = getHexSegment(is, hexStream, asciiStream);
 if (count <= 0)
...
int hexDump(InputStream is, PrintStream ps, int maxRead, int bytesPerLine)
hex Dump
int read, chr, i, result;
char[] pad;
StringBuffer left, right;
if (1 > bytesPerLine) {
 bytesPerLine = 1;
left = new StringBuffer();
right = new StringBuffer();
...
void hexDump(PrintStream out, String s, byte b[], int n)
hex Dump
if (out == null)
 return;
int i;
out.print(s);
for (i = 0; i < n; ++i) {
 int x = b[i];
 if (x < 0)
 x = 256 + x;
...
void hexDump(String prompt, byte[] bs)
hex Dump
PrintStream ps = new PrintStream(new BufferedOutputStream(System.out, 2048));
ps.printf("%s:", prompt);
for (byte b : bs)
 ps.printf("%02x ", b);
ps.printf("[");
for (byte b : bs)
 ps.printf("%c", Character.isLetterOrDigit(b) ? b : '.');
ps.printf("]\n");
...
void hexDumpBytes(PrintStream out, long offset, byte[] bytes)
hex Dump Bytes
final int lineWidth = 16;
char[] line = new char[lineWidth * 3];
for (int i = 0; i < bytes.length; i += lineWidth) {
 int len = Math.min(bytes.length - i, 16);
 for (int j = 0; j < len; j++) {
 int value = bytes[i + j] & 0xFF;
 line[j * 3 + 0] = hexArray[value >>> 4];
 line[j * 3 + 1] = hexArray[value & 0x0F];
...


AltStyle によって変換されたページ (->オリジナル) /