Class BinaryDump


  • public final class BinaryDump
    extends Object
    This class allows to produce various dump of bytes arrays.
    • Field Detail

      • EOL

        public static final String EOL
      • _hexcodes

        private static final char[] _hexcodes
      • _shifts

        private static final int[] _shifts
    • Constructor Detail

      • BinaryDump

        public BinaryDump()
    • 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
      • dump

        private static String dump​(long value)
      • dump

        private static String dump​(byte value)
      • toJSon

        public static String toJSon​(byte[] data)
      • toJSon

        public static String toJSon​(byte[] data,
                                    int offset,
                                    int length)
      • toJSon

        public static void toJSon​(StringBuilder strbuf,
                                  byte[] data)
      • toJSon

        public static void toJSon​(StringBuilder strbuf,
                                  byte[] data,
                                  int offset,
                                  int length)
      • toHex

        public static String toHex​(byte[] value)
        Dumps the byte array in hexadecimal format.
        Parameters:
        value - The value to convert
        Returns:
        A String representing the array of bytes
      • toHex

        public static String toHex​(byte[] value,
                                   int offset,
                                   int length)
        dump a part of the array of bytes to a String
        Parameters:
        value - the byte array to be dumped
        offset - starting index into the byte array
        length - length of the byte array to dump.
        Returns:
        output string
      • 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​(byte value)
        Converts the parameter to a hex value.
        Parameters:
        value - The value to convert
        Returns:
        The result right padded with 0
      • toHex

        private static String toHex​(long value,
                                    int digits)