Android Hex String Create isHex(String sampleData)

Here you can find the source of isHex(String sampleData)

Description

Return true if the argument string seems to be a Hex data string, like "a0 13 2f ".

Declaration

public static final boolean isHex(String sampleData) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from   ww w  .  j a  va  2 s . c om
     * Return true if the argument string seems to be a Hex data string, like
     * "a0 13 2f ". Whitespace is ignored.
     */
    public static final boolean isHex(String sampleData) {
        for (int i = 0; i < sampleData.length(); i++) {
            if (!isHexStringChar(sampleData.charAt(i)))
                return false;
        }
        return true;
    }

    public static final boolean isHexStringChar(char c) {
        return (Character.isDigit(c) || Character.isWhitespace(c) || (("0123456789abcdefABCDEF"
                .indexOf(c)) >= 0));
    }
}

Related

  1. hexValue(char c)
  2. isHex(char c)
  3. getHexString(int[] b)
  4. getHexString(int[] b, String splitString)
  5. getHexString(int i)
  6. isHexStringChar(char c)
  7. FileNamePathExtension(String filename)
  8. pathExtension(String fileName)
  9. hexStringToBytes(String hexString)