Class HexDump


  • @Internal
    public final class HexDump
    extends java.lang.Object
    dump data in hexadecimal format
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String EOL  
      static java.nio.charset.Charset UTF8  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String byteToHex​(int value)  
      static java.lang.String dump​(byte[] data, long offset, int index)
      dump an array of bytes to a String
      static java.lang.String dump​(byte[] data, long offset, int index, int length)
      dump an array of bytes to a String
      static void dump​(byte[] data, long offset, java.io.OutputStream stream, int index)
      dump an array of bytes to an OutputStream
      static void dump​(byte[] data, long offset, java.io.OutputStream stream, int index, int length)
      dump an array of bytes to an OutputStream
      static java.lang.String intToHex​(int value)  
      static java.lang.String longToHex​(long value)  
      static java.lang.String shortToHex​(int value)  
      static char toAscii​(int dataB)  
      static java.lang.String toHex​(byte value)
      Converts the parameter to a hex value.
      static java.lang.String toHex​(byte[] value)
      Converts the parameter to a hex value.
      static java.lang.String toHex​(int value)
      Converts the parameter to a hex value.
      static java.lang.String toHex​(long value)
      Converts the parameter to a hex value.
      static java.lang.String toHex​(short value)
      Converts the parameter to a hex value.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EOL

        public static final java.lang.String EOL
      • UTF8

        public static final java.nio.charset.Charset UTF8
    • Method Detail

      • dump

        public static void dump​(byte[] data,
                                long offset,
                                java.io.OutputStream stream,
                                int index,
                                int length)
                         throws java.io.IOException,
                                java.lang.ArrayIndexOutOfBoundsException,
                                java.lang.IllegalArgumentException
        dump an array of bytes to an OutputStream
        Parameters:
        data - the byte array to be dumped
        offset - its offset, whatever that might mean
        stream - the OutputStream to which the data is to be written
        index - initial index into the byte array
        length - number of characters to output
        Throws:
        java.io.IOException - is thrown if anything goes wrong writing the data to stream
        java.lang.ArrayIndexOutOfBoundsException - if the index is outside the data array's bounds
        java.lang.IllegalArgumentException - if the output stream is null
      • dump

        public static void dump​(byte[] data,
                                long offset,
                                java.io.OutputStream stream,
                                int index)
                         throws java.io.IOException,
                                java.lang.ArrayIndexOutOfBoundsException,
                                java.lang.IllegalArgumentException
        dump an array of bytes to an OutputStream
        Parameters:
        data - the byte array to be dumped
        offset - its offset, whatever that might mean
        stream - the OutputStream to which the data is to be written
        index - initial index into the byte array
        Throws:
        java.io.IOException - is thrown if anything goes wrong writing the data to stream
        java.lang.ArrayIndexOutOfBoundsException - if the index is outside the data array's bounds
        java.lang.IllegalArgumentException - if the output stream is null
      • dump

        public static java.lang.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:
        java.lang.ArrayIndexOutOfBoundsException - if the index is outside the data array's bounds
      • dump

        public static java.lang.String dump​(byte[] data,
                                            long offset,
                                            int index,
                                            int length)
        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
        length - number of characters to output
        Returns:
        output string
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - if the index is outside the data array's bounds
      • toAscii

        public static char toAscii​(int dataB)
      • toHex

        public static java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.String toHex​(long value)
        Converts the parameter to a hex value.
        Parameters:
        value - The value to convert
        Returns:
        The result right padded with 0
      • longToHex

        public static java.lang.String longToHex​(long value)
        Returns:
        string of 16 (zero padded) uppercase hex chars and prefixed with '0x'
      • intToHex

        public static java.lang.String intToHex​(int value)
        Returns:
        string of 8 (zero padded) uppercase hex chars and prefixed with '0x'
      • shortToHex

        public static java.lang.String shortToHex​(int value)
        Returns:
        string of 4 (zero padded) uppercase hex chars and prefixed with '0x'
      • byteToHex

        public static java.lang.String byteToHex​(int value)
        Returns:
        string of 2 (zero padded) uppercase hex chars and prefixed with '0x'