可以通过捕捉异常来实现。
String strSource = "abcd12345";
try
{
  int iResult = Integer.parseInt(strSource);//如果是數字字符串不会抛出异常
  //double,float类似.
}
catch(Exception eNumber)
{
  System.err.println("出错:"+eNumber);
}

解决方案 »

  1.   

    自己编写:
    boolean isNumber(String s) {
    }
      

  2.   

    肯定是用Integer.parseInt(str);啦,方便不用自己写什么isNumber
      

  3.   

    用正则表达式,JDK1.4中已经提供了正则表达式了
    如果发现字串中有符合下列条件的
    [^0-9]
    则含有非数字字串。
    (find("[^0-9]","13312412344513241234123"))public static boolean find(String Pattern,String Matcher){
      java.util.regex.Pattern p=java.util.regex.Pattern.compile(Pattern);
      java.util.regex.Matcher m=p.matcher(Matcher);
      return m.find();
    }
      

  4.   

    用这个试试:
      try{
        if ( ! (new Double(s)).isNaN() ) {  //s is a string       System.out.println("It's a number.");
         }
      }catch(Exception e){       System.out.println("It's not a number.");
      }
      

  5.   

    同意用捕获异常的方法来判断.或者你写一个
    public boolean isNumberStr(String s)
    {
        boolean result = false;
        try
        {
             Integer number = new Integer(s);
             result = true;
        }catch (Exception ex)
        {
            System.out.println("It's not a number string: " + s);
            result = false;
        }
        return result;
    }