java判断是否为整数

/**
* 判断是否为整数
*
* @param str 传入的字符串
* @return 是整数返回true,否则返回false
*/
public static boolean isInteger(String str) {
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
return pattern.matcher(str).matches();
}

posted @ 2014-10-08 16:38  也许还年轻  阅读(6051)  评论(0编辑  收藏  举报