Android String to Number Convert isNumeric(String string)

Here you can find the source of isNumeric(String string)

Description

Tests if a string is numeric, i.e.

Parameter

Parameter Description
string string to test

Return

true if only digit chars, false if empty or null or contains non-digit chrs

Declaration

public static boolean isNumeric(String string) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from   ww w . j  av a 2  s .  c o m*/
     * Tests if a string is numeric, i.e. contains only digit characters
     * 
     * @param string
     *            string to test
     * @return true if only digit chars, false if empty or null or contains
     *         non-digit chrs
     */
    public static boolean isNumeric(String string) {
        if (string == null || string.length() == 0)
            return false;

        int l = string.length();
        for (int i = 0; i < l; i++) {
            if (!Character.isDigit(string.codePointAt(i)))
                return false;
        }
        return true;
    }
}

Related

  1. isNumeric(String str)
  2. isNumeric(String str)
  3. isNumeric(String str)
  4. isNumeric(String str)
  5. isLetterNumeric(String s)
  6. isNumericOnly(String pString)
  7. isNumeric(String str)
  8. containsNonNumericCharacters(String rawInput)