public static boolean isHexString(final String string) {
    Preconditions.checkNotNull(string, "Error: String argument can't be null");

    final CharMatcher cm =
        CharMatcher.inRange('0', '9')
            .or(CharMatcher.inRange('a', 'z'))
            .or(CharMatcher.inRange('A', 'F'));
    for (int i = 0; i < string.length(); i++) {
      if (!cm.apply(string.charAt(i))) {
        return false;
      }
    }

    return string.length() != 0;
  }
Tests whether a given string is a valid hexadecimal string.

@param string The string to check.
@return True, if the string is a valid hexadecimal string. False, otherwise.
java/zylib/src/main/java/com/google/security/zynamics/zylib/general/Convert.java