Class Hex


  • public final class Hex
    extends java.lang.Object
    Encodes and decodes to and from hexadecimal notation.
    Since:
    5.7
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static char[] HEX  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Hex()
      Defeats instantiation.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] decode​(java.lang.String s)
      Decode a hexadecimal string to a byte array.
      static java.lang.String toHexString​(byte[] b)
      Encode a byte array to a hexadecimal string.
      • Methods inherited from class java.lang.Object

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

      • HEX

        private static final char[] HEX
    • Constructor Detail

      • Hex

        private Hex()
        Defeats instantiation.
    • Method Detail

      • decode

        public static byte[] decode​(java.lang.String s)
        Decode a hexadecimal string to a byte array. Note this method validates that characters in the given string are valid as digits in a hex string.
        Parameters:
        s - hexadecimal string
        Returns:
        decoded array
      • toHexString

        public static java.lang.String toHexString​(byte[] b)
        Encode a byte array to a hexadecimal string.
        Parameters:
        b - byte array
        Returns:
        hexadecimal string