Class HexUtils


  • public class HexUtils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      HexUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] hexToBytes​(java.lang.CharSequence s)
      Converts a hexadecimal string to a byte array.
      static java.lang.String toHexString​(byte[] bytes)
      Converts a byte array to a hexadecimal string.
      static java.lang.String toHexString​(byte[] bytes, int offset, int endIndex)
      Converts a byte array to a hexadecimal string with a specified offset and end index.
      static void toHexString​(byte[] bytes, int offset, int endIndex, char[] hexChars, int destOffset)
      Converts a byte array to a hexadecimal string with a specified offset and end index.
      static void toHexString​(byte[] bytes, int offset, int endIndex, AString hexChars)
      Converts a byte array to a hexadecimal string with a specified offset and end index.
      static void toHexString​(int bytes, char[] hexChars, int destOffset)
      Converts an integer to a hexadecimal string with a specified destination array and offset.
      static void toHexString​(int src, AString hexChars)
      Converts an integer to a hexadecimal string.
      static void toHexString​(long bytes, char[] hexChars, int destOffset)
      Converts a long integer to a hexadecimal string with a specified destination array and offset.
      static void toHexString​(long src, AString hexChars)
      Converts a long integer to a hexadecimal string.
      static char[] toHexString2​(byte[] bytes)  
      static char[] toHexString2​(byte[] bytes, int offset, int endIndex)
      Converts a byte array to a hexadecimal string with a specified offset and end index.
      • Methods inherited from class java.lang.Object

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

      • HexUtils

        public HexUtils()
    • Method Detail

      • hexToBytes

        public static byte[] hexToBytes​(java.lang.CharSequence s)
        Converts a hexadecimal string to a byte array.
        Parameters:
        s - The hexadecimal string
        Returns:
        A byte array representation of the hexadecimal string
      • toHexString

        public static java.lang.String toHexString​(byte[] bytes)
        Converts a byte array to a hexadecimal string.
        Parameters:
        bytes - The byte array
        Returns:
        A hexadecimal string representation of the byte array
      • toHexString2

        public static char[] toHexString2​(byte[] bytes)
      • toHexString

        public static java.lang.String toHexString​(byte[] bytes,
                                                   int offset,
                                                   int endIndex)
        Converts a byte array to a hexadecimal string with a specified offset and end index.
        Parameters:
        bytes - The byte array
        offset - The starting index
        endIndex - The ending index (exclusive)
        Returns:
        A hexadecimal string representation of the specified portion of the byte array
      • toHexString2

        public static char[] toHexString2​(byte[] bytes,
                                          int offset,
                                          int endIndex)
        Converts a byte array to a hexadecimal string with a specified offset and end index.
        Parameters:
        bytes - The byte array
        offset - The starting index
        endIndex - The ending index (exclusive)
        Returns:
        A hexadecimal string representation of the specified portion of the byte array
      • toHexString

        public static void toHexString​(byte[] bytes,
                                       int offset,
                                       int endIndex,
                                       char[] hexChars,
                                       int destOffset)
        Converts a byte array to a hexadecimal string with a specified offset and end index.
        Parameters:
        bytes - The byte array
        offset - The starting index
        endIndex - The ending index (exclusive)
        hexChars - The character array to store the result
        destOffset - The starting position in the destination array
      • toHexString

        public static void toHexString​(int src,
                                       AString hexChars)
        Converts an integer to a hexadecimal string.
        Parameters:
        src - The integer
        hexChars - The character array to store the result
      • toHexString

        public static void toHexString​(long src,
                                       AString hexChars)
        Converts a long integer to a hexadecimal string.
        Parameters:
        src - The long integer
        hexChars - The character array to store the result
      • toHexString

        public static void toHexString​(byte[] bytes,
                                       int offset,
                                       int endIndex,
                                       AString hexChars)
        Converts a byte array to a hexadecimal string with a specified offset and end index.
        Parameters:
        bytes - The byte array
        offset - The starting index
        endIndex - The ending index (exclusive)
        hexChars - The character array to store the result
      • toHexString

        public static void toHexString​(int bytes,
                                       char[] hexChars,
                                       int destOffset)
        Converts an integer to a hexadecimal string with a specified destination array and offset.
        Parameters:
        bytes - The integer
        hexChars - The character array to store the result
        destOffset - The starting position in the destination array
      • toHexString

        public static void toHexString​(long bytes,
                                       char[] hexChars,
                                       int destOffset)
        Converts a long integer to a hexadecimal string with a specified destination array and offset.
        Parameters:
        bytes - The long integer
        hexChars - The character array to store the result
        destOffset - The starting position in the destination array