Here you can find the source of isHex(String sampleData)
public static final boolean isHex(String sampleData)
//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)); } }