int isNumeric(String str) throws ErrorException {
for (int i = str.length(); --i >= 0;) {
if (!Character.isDigit(str.charAt(i)))
throw new ErrorException("不是正整数");
}
return Integer.parseInt(str);
}
throw也可以被认为返回int值