1、judge whether the input string is a number:
public boolean isNumber(String str) {
if(str==null)
return false;
return str.split("(^-)?\\d+(\\.)?\\d*").length == 0;
}
// use regex to check for the number ,and if the string is a number, the split method will return 0
for example: "a".split("a")will return 0