Class Hex

java.lang.Object
org.eclipse.jgit.util.Hex

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

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

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

    Modifier and Type
    Method
    Description
    static byte[]
    Decode a hexadecimal string to a byte array.
    static 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 Details

    • HEX

      private static final char[] HEX
  • Constructor Details

    • Hex

      private Hex()
      Defeats instantiation.
  • Method Details

    • decode

      public static byte[] decode(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 String toHexString(byte[] b)
      Encode a byte array to a hexadecimal string.
      Parameters:
      b - byte array
      Returns:
      hexadecimal string