刘磊-Lucien

开心工作生活每一天 (原创文章,转载请注明出处) (QQ:6509051欢迎交流)
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

方法:判断字符串是不是Integer

Posted on 2008-09-24 14:17  LiuLei  阅读(953)  评论(0)    收藏  举报

 

 /**
  *
判断字符串是不是Integer
  *
  * @param str
  * @return true OR false
  * @see isNumeric("abc") = false
  * @see isNumeric("123") = true
  */
 public static boolean isInteger(String str) { 
  boolean result = true;
  try {
   Integer.parseInt(str); 
  } catch (Exception e) {  
   result = false;
  }
  return result;
 }