public static boolean isNumeric(String string, boolean bAllowFormatting)
    {
        if ((string == null) || (string.length() == 0))
            return false;
        boolean bIsNumeric = true;
        for (int i = 0; i < string.length(); i++)
        {
            if (!Character.isDigit(string.charAt(i)))
            {
            	if ((!bAllowFormatting)
            		|| (Character.isLetter(string.charAt(i))))
            			bIsNumeric = false;
            }
        }
        return bIsNumeric;
    }
public static boolean isNumeric ( String string , boolean bAllowFormatting ) { if ( ( string == null ) || ( string . length ( ) == 0 ) ) return false ; boolean bIsNumeric = true ; for ( int i = 0 ; i < string . length ( ) ; i ++ ) { if ( ! Character . isDigit ( string . charAt ( i ) ) ) { if ( ( ! bAllowFormatting ) || ( Character . isLetter ( string . charAt ( i ) ) ) ) bIsNumeric = false ; } } return bIsNumeric ; }
Is this string a valid number?
@param string The string to check.
@return true if this string is a valid number (all characters numeric).