/**
* Determine if it is a Chinese character
*
* @param str
* @return
*/
public Static Boolean ISGBK (String str) {
char[] chars = Str.tochararray ();
boolean ISGBK = false;
for (int i = 0; i < chars.length; i++) {
byte[] bytes = ("" + chars[i]). GetBytes () ;
if (Bytes.length = = 2) {
int[] ints = new int[2];
ints[0] = bytes[0] & 0xff;
ints[1] = bytes[1] & 0xff;
if (ints[0] >= 0x81 && ints[0] <= 0xFE && ints[1] >= 0x40
& nbsp; && ints[1] <= 0xFE) {
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;ISGBK = true;
break;
}
}
}
return ISGBK;
}
/**
* To determine if it is garbled
*
* @param str
* @return
*/
public Static Boolean Ismessycode (String str) {
for (int i = 0; i < str.length (); i++) {
c Har C = Str.charat (i);
//when converting from Unicode encoding to a character set, if there is no corresponding encoding in that character set, you get 0x3f (that is, the question mark character?)
// When converting from another character set to a Unicode encoding, if the binary number does not identify any characters in the character set, the result is 0xfffd
//system.out.println ("---" + (int ) c);
if (int) c = = 0xfffd) {
//there is a garbled
// System.out.println ("There is garbled" + (int) c);
return true;
}
}
return false;
}
/**
* Determines whether a string is a double integer number
*
* @param str
* @return
*/
public static Boolean isdouble (String str) {
if (Stringutil.isnullorempty (str)) {
return false;
}
Pattern p = pattern.compile ("-*\\d*.\\d*");
Pattern p = pattern.compile ("-*" + "\\d*" + ".") + "\\d*");
return P.matcher (str). matches ();
}
/**
* Determines whether the string is an integer word
*
* @param str
* @return
*/
public static Boolean isnumber (String str) {
if (Stringutil.isnullorempty (str)) {
return false;
}
Pattern p = pattern.compile ("-*\\d*");
return P.matcher (str). matches ();
}
/**
* Judging whether it is a number
*
* @param str
* @return
*/
public static Boolean isnumeric (String str)
{
Pattern pattern = Pattern.compile ("[0-9]*");
Matcher isnum = Pattern.matcher (str);
if (!isnum.matches ()) {
return false;
}
return true;
}
Need to import Java.util.regex.Pattern and Java.util.regex.Matcher
From:http://hi.baidu.com/zdz8207/item/13abe809f904c718eafe38d5
Java determines whether a Chinese character is garbled to determine whether a string is a double integer number