Package loci.poi.util

Class HexDump


  • public class HexDump
    extends Object
    dump data in hexadecimal format; derived from a HexDump utility I wrote in June 2001.
    Author:
    Marc Johnson, Glen Stampoultzis (glens at apache.org)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String EOL  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static String dump​(byte[] data, long offset, int index)
      dump an array of bytes to a String
      static void dump​(byte[] data, long offset, OutputStream stream, int index)
      dump an array of bytes to an OutputStream
      static void dump​(byte[] data, long offset, OutputStream stream, int index, int length)
      dump an array of bytes to an OutputStream
      static void dump​(InputStream in, PrintStream out, int start, int bytesToDump)
      Dumps bytesToDump bytes to an output stream.
      static void main​(String[] args)  
      static String toHex​(byte value)
      Converts the parameter to a hex value.
      static String toHex​(byte[] value)
      Converts the parameter to a hex value.
      static String toHex​(byte[] value, int bytesPerLine)
      Converts the parameter to a hex value breaking the results into lines.
      static String toHex​(int value)
      Converts the parameter to a hex value.
      static String toHex​(long value)
      Converts the parameter to a hex value.
      static String toHex​(short value)
      Converts the parameter to a hex value.
      static String toHex​(short[] value)
      Converts the parameter to a hex value.
    • Field Detail

      • EOL

        public static final String EOL
    • Method Detail

      • dump

        public static String dump​(byte[] data,
                                  long offset,
                                  int index)
        dump an array of bytes to a String
        Parameters:
        data - the byte array to be dumped
        offset - its offset, whatever that might mean
        index - initial index into the byte array
        Returns:
        output string
        Throws:
        ArrayIndexOutOfBoundsException - if the index is outside the data array's bounds
      • toHex

        public static String toHex​(byte[] value)
        Converts the parameter to a hex value.
        Parameters:
        value - The value to convert
        Returns:
        A String representing the array of bytes
      • toHex

        public static String toHex​(short[] value)
        Converts the parameter to a hex value.
        Parameters:
        value - The value to convert
        Returns:
        A String representing the array of shorts
      • toHex

        public static String toHex​(byte[] value,
                                   int bytesPerLine)

        Converts the parameter to a hex value breaking the results into lines.

        Parameters:
        value - The value to convert
        bytesPerLine - The maximum number of bytes per line. The next byte will be written to a new line
        Returns:
        A String representing the array of bytes
      • toHex

        public static String toHex​(short value)
        Converts the parameter to a hex value.
        Parameters:
        value - The value to convert
        Returns:
        The result right padded with 0
      • toHex

        public static String toHex​(byte value)
        Converts the parameter to a hex value.
        Parameters:
        value - The value to convert
        Returns:
        The result right padded with 0
      • toHex

        public static String toHex​(int value)
        Converts the parameter to a hex value.
        Parameters:
        value - The value to convert
        Returns:
        The result right padded with 0
      • toHex

        public static String toHex​(long value)
        Converts the parameter to a hex value.
        Parameters:
        value - The value to convert
        Returns:
        The result right padded with 0
      • dump

        public static void dump​(InputStream in,
                                PrintStream out,
                                int start,
                                int bytesToDump)
                         throws IOException
        Dumps bytesToDump bytes to an output stream.
        Parameters:
        in - The stream to read from
        out - The output stream
        start - The index to use as the starting position for the left hand side label
        bytesToDump - The number of bytes to output. Use -1 to read until the end of file.
        Throws:
        IOException