java.lang.Object
net.i2p.util.HexDump

public class HexDumpextends Object
Hexdump class (well, it's actually a namespace with some functions, but let's stick with java terminology :-). These methods generate an output that resembles `hexdump -C` (Windows users: do you remember `debug` in the DOS age?).
  • Field Details

    • FORMAT_OFFSET_PADDING

      private static final int FORMAT_OFFSET_PADDING
      Width of the offset column.
      See Also:
    • FORMAT_BYTES_PER_ROW

      private static final int FORMAT_BYTES_PER_ROW
      Bytes shown on one line.
      See Also:
    • OUTPUT_BYTES_PER_ROW

      private static final int OUTPUT_BYTES_PER_ROW
      Width of one formatted line.
      See Also:
    • HEXCHARS

      private static final byte[] HEXCHARS
      Digits used when writing hex.
  • Constructor Details

    • HexDump

      private HexDump()
      Utility class.
  • Method Details

    • dump

      public static String dump(byte[] data)
      Dump a byte array in a String.
      Parameters:
      data - Data to be dumped
      Returns:
      the hexdump as a String
    • dump

      public static String dump(byte[] data, int off, int len)
      Dump a byte array in a String.
      Parameters:
      data - Data to be dumped
      off - Offset from the beginning of data
      len - Number of bytes of data to be dumped
      Returns:
      the hexdump as a String
    • dump

      public static void dump(byte[] data, OutputStream out) throws IOException
      Dump a byte array through a stream.
      Parameters:
      data - Data to be dumped
      out - receives the dump as offset, hex and printable-ASCII columns; not closed or flushed
      Throws:
      IOException - if the write fails
    • dump

      public static void dump(byte[] data, int off, int len, OutputStream out) throws IOException
      Dump a byte array through a stream.
      Parameters:
      data - Data to be dumped
      off - Offset from the beginning of data
      len - Number of bytes of data to be dumped
      out - receives the dump; not closed or flushed
      Throws:
      IOException - if the output stream rejects any of the writes making up the dump