Class HexTool

java.lang.Object
de.das.encrypter.tools.HexTool

public class HexTool extends Object
Methods for handling conversions of data types from and to byte arrays.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static float[]
    byteArrayToFloatArray(byte[] byteArray)
    Takes every 4 bytes of the byte array consecutively, converts it to a float value and places it to its correct place into the float array.
    static long
    byteArrayToLong(byte[] b)
    Converts the specified byte array, assumed to be a little endian, to a long value.
    static String
    byteArrayToString(byte[] data)
    Generates a string consisting of the string representations of the hexadecimal values of the given ByteArray separated by spaces.
    static String
    byteArrayToString(byte[] data, int blockSize)
    Generates a string consisting of the string representations of the hexadecimal values of the given ByteArray separated by spaces.
    static int
    byteToInt(byte b)
    Converts a byte to integer.
    static int
    byteToInt(byte[] bytes)
    Converts the specified byte array, assumed to be a little endian, to a long value.
    static int
    byteToInt(int msb, int lsb)
    Generates an integer value by composing it from the specified parts (msb and lsb).
    static int
    byteToInt(int msb, int csb, int lsb)
    Generates an integer value by composing it from the specified parts (msb, csb and lsb).
    static int
    byteToIntBigEndian(int pos, byte[] bytes)
    Converts an four-byte long part from the specified byte array starting at the specified position, assuming it is a big-endian value, to an integer value.
    static int
    byteToIntLittleEndian(int pos, byte[] bytes)
    Converts an four-byte long part from the specified byte array starting at the specified position, assuming it is a little-endian value, to an integer value.
    static long
    byteToLongBigEndian(byte[] bytes, int pos)
    Converts an eight-byte long part from the specified byte array starting at the specified position, assuming it is a big-endian value, to a long-int value.
    static long
    byteToLongLittleEndian(byte[] bytes)
    Converts the specified byte array, assumed to be a little endian, to a long int value.
    static long
    byteToLongLittleEndian(byte[] bytes, int pos)
    Converts an eight-byte long part from the specified byte array starting at the specified position, assuming it is a little-endian value, to a long-int value.
    static short
    byteToShortIntBigEndian(int pos, byte[] bytes)
    Converts an two-byte long part from the specified byte array starting at the specified position, assuming it is a big-endian value, to a short integer value.
    static short
    byteToShortIntLittleEndian(int pos, byte[] bytes)
    Converts an two-byte long part from the specified byte array starting at the specified position, assuming it is a little-endian value, to a short int value.
    static String
    byteToString(byte[] data, int start, int length)
    Creates a string using the specified part of the given byte array.
    static long
    byteToUintBigEndian(int pos, byte[] bytes)
    Converts an four-byte long part from the specified byte array starting at the specified position, assuming it is a big-endian value, to an unsigned integer value.
    static long
    byteToUintLittleEndian(int pos, byte[] bytes)
    Converts an four-byte long part from the specified byte array starting at the specified position, assuming it is a little-endian value, to an unsigned integer value.
    static short
    byteToWord(int msb, int lsb)
    Generates a short integer value by composing it from the specified parts (msb and lsb).
    static int
    byteToWordBigEndian(int pos, byte[] bytes)
    Converts an two-byte long part from the specified byte array starting at the specified position, assuming it is a big-endian value, to an integer value.
    static int
    byteToWordLittleEndian(int pos, byte[] bytes)
    Converts an two-byte long part from the specified byte array starting at the specified position, assuming it is a little-endian value, to an integer value.
    static String
    Generates a string representing a formatted hex list with sixteen bytes per line and a preceding eight-character hexadecimal address.
    static String
    createFormattedHexList(byte[] data, String centerDiv)
    Generates a string representing a formatted hex list with sixteen bytes per line and a preceding eight-character hexadecimal address.
    static String
    createFormattedHexList(int adr, byte[] data, String centerDiv)
    Generates a string representing a formatted hex list with sixteen bytes per line and a preceding eight-character hexadecimal address.
    static String
    fillLeadingPositions(String s, int n, char c)
    Expands the string "s" if its length is smaller than the given length "n" by adding leading characters "c".
    static byte[]
    floatArrayToByteArray(float[] fArray)
    Maps the 4 bytes of each float value to its correct place into the byte array.
    static byte[]
    Assigns the four bytes representing a floating point value to a byte array with bit 31 of the floating point at bit 7 of byte at position "0".
    static float
    getFloatAt(int pos, byte[] data)
    Converts the four bytes at the given starting position to a floating point value assuming the byte order as little endian.
    static String
    getHexString(byte[] data)
    Converts the byte values of the byte array into hex strings and arranges them one after another separated by spaces.
    static int
    getIntAt(int pos, byte[] data)
    Converts the four bytes at the given starting position to an integer value assuming as little endian.
    static long
    getLongAt(int pos, byte[] data)
    Converts the eight bytes at the given starting position to a long value assuming as little endian.
    static void
    insertFloatAt(int pos, float fValue, byte[] data)
    Converts a the float four bytes representation into an integer and places the four bytes of the integer into the byte array from the given position on.
    static void
    insertIntAt(int v, int pos, byte[] data)
    Assigns the four bytes of an integer value to the bytes of the given byte array starting at the specified position with byte order big endian.
    static void
    insertIntAt(long v, int pos, byte[] data)
    Deprecated.
    Use insertIntBigEndianAt instead.
    static void
    insertIntBigEndianAt(long v, int pos, byte[] data)
    Assigns the four lsb bytes of a long value to the bytes of the given byte array starting at the specified position with byte order big endian.
    static void
    insertIntLittleEndianAt(long v, int pos, byte[] data)
    Assigns the four lsb bytes of a long value to the bytes of the given byte array starting at the specified position with byte order little endian.
    static void
    insertLongLittleEndianAt(long v, int pos, byte[] data)
    Assigns the eight bytes of a long value to the bytes of the given byte array starting at the specified position with byte order little endian.
    static void
    insertShortIntAt(int v, int pos, byte[] data)
    Deprecated.
    Use insertShortIntBigEndianAt instead.
    static void
    insertShortIntBigEndianAt(int v, int pos, byte[] data)
    Assigns the two lsb bytes of an int value to the bytes of the given byte array starting at the specified position with byte order big endian.
    static void
    insertShortIntLittleEndianAt(int v, int pos, byte[] data)
    Assigns the two lsb bytes of an int value to the bytes of the given byte array starting at the specified position with byte order little endian.
    static byte[]
    Converts the given int value into a byte array of length 4.
    static byte[]
    Deprecated.
    Use "longToByteArrayLittleEndian" instead.
    static byte[]
    Converts the given long value into a byte array of length 8.
    static byte[]
    Converts the given long value into a byte array of length 8.
    static byte
    Converts a string of length two, assumed to be the representation of a hex value, to a byte.
    static short
    Converts a string of length four, assumed to be the representation of a hex value, to a byte.
    static void
    printBuffer(byte[] data)
    Converts the specified byte array to a hex string and outputs it over the System.out print stream.
    static void
    printBuffer(PrintStream out, byte[] data)
    Converts the specified byte array to a hex string and outputs it over the specified print stream.
    static void
    printlnBuffer(byte[] data)
    Converts the specified byte array to a hex string and outputs it over the System.out print stream followed by a System.out.println().
    static String
    Creates a string from the bytes of a byte array.
    static byte[]
    Creates a byte array with the bytes representing the characters of the specified string.
    static byte[]
    swapBytes(byte[] data)
    Reverses the order of the bytes in a byte array.
    static String
    toHex(byte b)
    Creates a two character string representing the given byte value.
    static String
    toHexQuad(short sh)
    Creates a four character string representing the given short value.
    static String
    toTwoHexQuad(int i)
    Creates an eight character string representing the given integer value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HexTool

      public HexTool()
  • Method Details

    • byteArrayToFloatArray

      public static float[] byteArrayToFloatArray(byte[] byteArray)
      Takes every 4 bytes of the byte array consecutively, converts it to a float value and places it to its correct place into the float array.
      Parameters:
      byteArray - is a given array with bytes representing float values.
      Returns:
      a float array containing the the float values converted from the byte array.
    • byteToInt

      public static int byteToInt(byte b)
      Converts a byte to integer. Unlike simple casting, which would yield the range [-128 .. 127], this method yields the range [0 .. 255].
      Parameters:
      b - a byte value.
      Returns:
      an integer value in the range [0 .. 255].
    • floatArrayToByteArray

      public static byte[] floatArrayToByteArray(float[] fArray)
      Maps the 4 bytes of each float value to its correct place into the byte array. The resulting byte array will have the size (4 * fArray.length).
      Parameters:
      fArray - is a given array with float values.
      Returns:
      a byte array containing the bytes of the float values from the float array.
    • floatToByteArray

      public static byte[] floatToByteArray(float f)
      Assigns the four bytes representing a floating point value to a byte array with bit 31 of the floating point at bit 7 of byte at position "0".

      Bit 31 (the bit that is selected by the mask 0x80000000) represents the sign of the floating-point number.

      Bits 30-23 (the bits that are selected by the mask 0x7f800000) represent the exponent.

      Bits 22-0 (the bits that are selected by the mask 0x007fffff) represent the significand (sometimes called the mantissa) of the floating-point number .

      - If the argument is positive infinity, the result is 0x7f800000.

      - If the argument is negative infinity, the result is 0xff800000.

      - If the argument is NaN, the result is 0x7fc00000.
      Parameters:
      f - a float value.
      Returns:
      a byte array with the four float bytes.
    • longToByteArray

      public static byte[] longToByteArray(long v)
      Deprecated.
      Use "longToByteArrayLittleEndian" instead.
      Converts the given long value into a byte array of length 8. The msb is at position 7 and the lsb at position 0.
      Parameters:
      v - is the given long value.
      Returns:
      a byte array of length 8 containing the bytes of the long value.
    • longToByteArrayLittleEndian

      public static byte[] longToByteArrayLittleEndian(long v)
      Converts the given long value into a byte array of length 8. The msb is at position 7 and the lsb at position 0.
      Parameters:
      v - is the given long value.
      Returns:
      a byte array of length 8 containing the bytes of the long value.
    • longToByteArrayBigEndian

      public static byte[] longToByteArrayBigEndian(long v)
      Converts the given long value into a byte array of length 8. The msb is at position 7 and the lsb at position 0.
      Parameters:
      v - is the given long value.
      Returns:
      a byte array of length 8 containing the bytes of the long value.
    • intToByteArray

      public static byte[] intToByteArray(int v)
      Converts the given int value into a byte array of length 4. The msb is at position 3 and the lsb at position 0 (little endian).
      Parameters:
      v - is the given int value.
      Returns:
      a byte array of length 4 containing the bytes of the int value.
    • byteArrayToLong

      public static long byteArrayToLong(byte[] b)
      Converts the specified byte array, assumed to be a little endian, to a long value.
      Parameters:
      b - a byte array representing a long value.
      Returns:
      a long value from the given byte array.
    • stringFromByteArray

      public static String stringFromByteArray(byte[] b)
      Creates a string from the bytes of a byte array. If the byte array contains 0x00 values, only the values up to the position of the first occurrence of a 0x00 value are used.
      Parameters:
      b - a given byte array.
      Returns:
      a string built from the bytes of the given byte array.
    • stringToByteArray

      public static byte[] stringToByteArray(String str)
      Creates a byte array with the bytes representing the characters of the specified string. The method is equivalent to the "getBytes()" method of the String class. UTF-8 character set is used for conversion.
      Parameters:
      str - a given string.
      Returns:
      a byte array with bytes representing the characters of the string.
    • toHex

      public static String toHex(byte b)
      Creates a two character string representing the given byte value.
      Parameters:
      b - a given byte value.
      Returns:
      the string representation of the hex value [00 .. FF]
    • toTwoHexQuad

      public static String toTwoHexQuad(int i)
      Creates an eight character string representing the given integer value.
      Parameters:
      i - a given integer value.
      Returns:
      the string representation of the hex value [00000000 .. FFFFFFFF]
    • toHexQuad

      public static String toHexQuad(short sh)
      Creates a four character string representing the given short value.
      Parameters:
      sh - a given short value.
      Returns:
      the string representation of the hex value [0000 .. FFFF]
    • parseHex

      public static byte parseHex(String str) throws NumberFormatException
      Converts a string of length two, assumed to be the representation of a hex value, to a byte. Allowed characters: [0 .. 9, A .. F, a .. f].
      Parameters:
      str - a string representing a hex value [00 .. FF].
      Returns:
      the converted byte value.
      Throws:
      NumberFormatException - if one of the characters is not allowed.
    • fillLeadingPositions

      public static String fillLeadingPositions(String s, int n, char c)
      Expands the string "s" if its length is smaller than the given length "n" by adding leading characters "c".
      Parameters:
      s - the given string.
      n - the requested length.
      c - the character with which the string is filled.
      Returns:
      the expanded string.
    • parseQuadHex

      public static short parseQuadHex(String str) throws NumberFormatException
      Converts a string of length four, assumed to be the representation of a hex value, to a byte. Allowed characters: [0 .. 9, A .. F, a .. f].
      Parameters:
      str - a string representing a hex value [0000 .. FFFF].
      Returns:
      the converted byte value.
      Throws:
      NumberFormatException - if one of the characters is not allowed.
    • byteToWord

      public static short byteToWord(int msb, int lsb)
      Generates a short integer value by composing it from the specified parts (msb and lsb).
      Parameters:
      msb - the msb part of the short int value.
      lsb - the lsb part of the short int value.
      Returns:
      a short integer value by composing it from the specified parts.
    • byteToInt

      public static int byteToInt(int msb, int lsb)
      Generates an integer value by composing it from the specified parts (msb and lsb).
      Parameters:
      msb - the msb part of the int value.
      lsb - the lsb part of the int value.
      Returns:
      an integer value by composing it from the specified parts.
    • byteToInt

      public static int byteToInt(int msb, int csb, int lsb)
      Generates an integer value by composing it from the specified parts (msb, csb and lsb).
      Parameters:
      msb - the msb part of the int value.
      csb - the csb part of the int value.
      lsb - the lsb part of the int value.
      Returns:
      an integer value by composing it from the specified parts.
    • byteToInt

      public static int byteToInt(byte[] bytes)
      Converts the specified byte array, assumed to be a little endian, to a long value.
      Parameters:
      bytes - a byte array representing a integer value.
      Returns:
      an integer value from the given byte array.
    • byteToLongLittleEndian

      public static long byteToLongLittleEndian(byte[] bytes)
      Converts the specified byte array, assumed to be a little endian, to a long int value.
      Parameters:
      bytes - a byte array representing a long int value.
      Returns:
      a long int value from the given byte array.
    • byteToLongLittleEndian

      public static long byteToLongLittleEndian(byte[] bytes, int pos)
      Converts an eight-byte long part from the specified byte array starting at the specified position, assuming it is a little-endian value, to a long-int value.
      Parameters:
      bytes - a given byte array.
      pos - the position within the byte array where the eight byte long part starts.
      Returns:
      a long int value from the given byte array at the specified positon.
    • byteToIntLittleEndian

      public static int byteToIntLittleEndian(int pos, byte[] bytes)
      Converts an four-byte long part from the specified byte array starting at the specified position, assuming it is a little-endian value, to an integer value.
      Parameters:
      bytes - a given byte array.
      pos - the position within the byte array where the four byte long part starts.
      Returns:
      an integer value from the given byte array at the specified positon.
    • byteToLongBigEndian

      public static long byteToLongBigEndian(byte[] bytes, int pos)
      Converts an eight-byte long part from the specified byte array starting at the specified position, assuming it is a big-endian value, to a long-int value.
      Parameters:
      bytes - a given byte array.
      pos - the position within the byte array where the eight byte long part starts.
      Returns:
      a long int value from the given byte array at the specified positon.
    • byteToUintLittleEndian

      public static long byteToUintLittleEndian(int pos, byte[] bytes)
      Converts an four-byte long part from the specified byte array starting at the specified position, assuming it is a little-endian value, to an unsigned integer value.
      Parameters:
      bytes - a given byte array.
      pos - the position within the byte array where the four byte long part starts.
      Returns:
      an unsigned integer value from the given byte array at the specified positon.
    • byteToIntBigEndian

      public static int byteToIntBigEndian(int pos, byte[] bytes)
      Converts an four-byte long part from the specified byte array starting at the specified position, assuming it is a big-endian value, to an integer value.
      Parameters:
      bytes - a given byte array.
      pos - the position within the byte array where the four byte long part starts.
      Returns:
      an integer value from the given byte array at the specified positon.
    • byteToUintBigEndian

      public static long byteToUintBigEndian(int pos, byte[] bytes)
      Converts an four-byte long part from the specified byte array starting at the specified position, assuming it is a big-endian value, to an unsigned integer value.
      Parameters:
      bytes - a given byte array.
      pos - the position within the byte array where the four byte long part starts.
      Returns:
      an unsigned integer value from the given byte array at the specified positon.
    • byteToWordLittleEndian

      public static int byteToWordLittleEndian(int pos, byte[] bytes)
      Converts an two-byte long part from the specified byte array starting at the specified position, assuming it is a little-endian value, to an integer value.
      Parameters:
      bytes - a given byte array.
      pos - the position within the byte array where the two byte long part starts.
      Returns:
      an integer value from the given byte array at the specified positon.
    • byteToWordBigEndian

      public static int byteToWordBigEndian(int pos, byte[] bytes)
      Converts an two-byte long part from the specified byte array starting at the specified position, assuming it is a big-endian value, to an integer value.
      Parameters:
      bytes - a given byte array.
      pos - the position within the byte array where the two byte long part starts.
      Returns:
      an integer value from the given byte array at the specified positon.
    • byteToShortIntBigEndian

      public static short byteToShortIntBigEndian(int pos, byte[] bytes)
      Converts an two-byte long part from the specified byte array starting at the specified position, assuming it is a big-endian value, to a short integer value.
      Parameters:
      bytes - a given byte array.
      pos - the position within the byte array where the two byte long part starts.
      Returns:
      a short integer value from the given byte array at the specified positon.
    • byteToShortIntLittleEndian

      public static short byteToShortIntLittleEndian(int pos, byte[] bytes)
      Converts an two-byte long part from the specified byte array starting at the specified position, assuming it is a little-endian value, to a short int value.
      Parameters:
      bytes - a given byte array.
      pos - the position within the byte array where the two byte long part starts.
      Returns:
      a short integer value from the given byte array at the specified positon.
    • byteToString

      public static String byteToString(byte[] data, int start, int length)
      Creates a string using the specified part of the given byte array. The part is specified by a starting index and the number of byte to be used.
      Parameters:
      data - a given byte array.
      start - a starting index.
      length - the number of byte to be used.
      Returns:
      a string built from a part of the byte array.
    • byteArrayToString

      public static String byteArrayToString(byte[] data)
      Generates a string consisting of the string representations of the hexadecimal values of the given ByteArray separated by spaces.
      Parameters:
      data - a given byte array.
      Returns:
      a string with the hex values of the given byte array.
    • byteArrayToString

      public static String byteArrayToString(byte[] data, int blockSize)
      Generates a string consisting of the string representations of the hexadecimal values of the given ByteArray separated by spaces. If the block size "n" is greater than "0", hyphens are inserted between blocks with "n" hex numbers.
      Parameters:
      data - a given byte array.
      blockSize - number of hex values per block.
      Returns:
      a string with the hex values of the given byte array.
    • insertIntAt

      public static void insertIntAt(int v, int pos, byte[] data)
      Assigns the four bytes of an integer value to the bytes of the given byte array starting at the specified position with byte order big endian.
      Parameters:
      v - a given integer value.
      pos - the starting position in the byte array.
      data - a given byte array.
    • insertIntAt

      public static void insertIntAt(long v, int pos, byte[] data)
      Deprecated.
      Use insertIntBigEndianAt instead.
      Assigns the four bytes of a long value to the bytes of the given byte array starting at the specified position with byte order big endian.
      Parameters:
      v - a given long value.
      pos - the starting position in the byte array.
      data - a given byte array.
    • insertIntBigEndianAt

      public static void insertIntBigEndianAt(long v, int pos, byte[] data)
      Assigns the four lsb bytes of a long value to the bytes of the given byte array starting at the specified position with byte order big endian.
      Parameters:
      v - a given long value.
      pos - the starting position in the byte array.
      data - a given byte array.
    • insertIntLittleEndianAt

      public static void insertIntLittleEndianAt(long v, int pos, byte[] data)
      Assigns the four lsb bytes of a long value to the bytes of the given byte array starting at the specified position with byte order little endian.
      Parameters:
      v - a given long value.
      pos - the starting position in the byte array.
      data - a given byte array.
    • insertLongLittleEndianAt

      public static void insertLongLittleEndianAt(long v, int pos, byte[] data)
      Assigns the eight bytes of a long value to the bytes of the given byte array starting at the specified position with byte order little endian.
      Parameters:
      v - a given long value.
      pos - the starting position in the byte array.
      data - a given byte array.
    • insertShortIntAt

      public static void insertShortIntAt(int v, int pos, byte[] data)
      Deprecated.
      Use insertShortIntBigEndianAt instead.
      Assigns the two lsb bytes of an int value to the bytes of the given byte array starting at the specified position with byte order big endian.
      Parameters:
      v - a given integer value.
      pos - the starting position in the byte array.
      data - a given byte array.
    • insertShortIntBigEndianAt

      public static void insertShortIntBigEndianAt(int v, int pos, byte[] data)
      Assigns the two lsb bytes of an int value to the bytes of the given byte array starting at the specified position with byte order big endian.
      Parameters:
      v - a given integer value.
      pos - the starting position in the byte array.
      data - a given byte array.
    • insertShortIntLittleEndianAt

      public static void insertShortIntLittleEndianAt(int v, int pos, byte[] data)
      Assigns the two lsb bytes of an int value to the bytes of the given byte array starting at the specified position with byte order little endian.
      Parameters:
      v - a given integer value.
      pos - the starting position in the byte array.
      data - a given byte array.
    • insertFloatAt

      public static void insertFloatAt(int pos, float fValue, byte[] data)
      Converts a the float four bytes representation into an integer and places the four bytes of the integer into the byte array from the given position on.
      Parameters:
      pos - is the position in the byte array where the float value has to be placed at.
      fValue - is the float value to be placed into the byte array.
      data - is the byte array the float value shall be written to.
    • getFloatAt

      public static float getFloatAt(int pos, byte[] data)
      Converts the four bytes at the given starting position to a floating point value assuming the byte order as little endian.
      Parameters:
      pos - starting position in the byte array.
      data - a given byte array.
      Returns:
      an integer value.
    • getIntAt

      public static int getIntAt(int pos, byte[] data)
      Converts the four bytes at the given starting position to an integer value assuming as little endian.
      Parameters:
      pos - starting position in the byte array.
      data - a given byte array.
      Returns:
      an integer value.
    • getLongAt

      public static long getLongAt(int pos, byte[] data)
      Converts the eight bytes at the given starting position to a long value assuming as little endian.
      Parameters:
      pos - starting position in the byte array.
      data - a given byte array.
      Returns:
      a long value.
    • getHexString

      public static String getHexString(byte[] data)
      Converts the byte values of the byte array into hex strings and arranges them one after another separated by spaces.
      Parameters:
      data - a given byte array.
      Returns:
      a string with hex string separated by spaces.
    • printBuffer

      public static void printBuffer(PrintStream out, byte[] data)
      Converts the specified byte array to a hex string and outputs it over the specified print stream.
      Parameters:
      out - a given print stream.
      data - a given byte array.
    • printBuffer

      public static void printBuffer(byte[] data)
      Converts the specified byte array to a hex string and outputs it over the System.out print stream.
      Parameters:
      data - a given byte array.
    • printlnBuffer

      public static void printlnBuffer(byte[] data)
      Converts the specified byte array to a hex string and outputs it over the System.out print stream followed by a System.out.println().
      Parameters:
      data - a given byte array.
    • createFormattedHexList

      public static String createFormattedHexList(byte[] data)
      Generates a string representing a formatted hex list with sixteen bytes per line and a preceding eight-character hexadecimal address. The start value for the addresses is assumed to be zero. The string inserted between the eighth and ninth hexadecimal value in each line is assumed to two spaces.
      Parameters:
      data - a given byte array.
      Returns:
      a string representing a formatted hex list.
    • createFormattedHexList

      public static String createFormattedHexList(byte[] data, String centerDiv)
      Generates a string representing a formatted hex list with sixteen bytes per line and a preceding eight-character hexadecimal address. The start value for the addresses is assumed to be zero.
      Parameters:
      data - a given byte array.
      centerDiv - a string inserted between the eighth and ninth hexadecimal value in each line.
      Returns:
      a string representing a formatted hex list.
    • createFormattedHexList

      public static String createFormattedHexList(int adr, byte[] data, String centerDiv)
      Generates a string representing a formatted hex list with sixteen bytes per line and a preceding eight-character hexadecimal address.
      Parameters:
      adr - a given start value for the preceding address.
      data - a given byte array.
      centerDiv - a string inserted between the eighth and ninth hexadecimal value in each line.
      Returns:
      a string representing a formatted hex list.
    • swapBytes

      public static byte[] swapBytes(byte[] data)
      Reverses the order of the bytes in a byte array.
      Parameters:
      data - a given byte array.
      Returns:
      the byte array where the order of the bytes was reversed.