Here you can find the source of isNumber(String str)
Parameter | Description |
---|---|
str | a parameter |
public static boolean isNumber(String str)
//package com.java2s; //License from project: Apache License import java.text.NumberFormat; import java.text.ParsePosition; public class Main { /**//w w w . j a va 2s. c o m * This method is used to check if the String passed is a number/integer only. * @param str * @return boolean */ public static boolean isNumber(String str) { NumberFormat formatter = NumberFormat.getInstance(); ParsePosition pos = new ParsePosition(0); formatter.parse(str, pos); return str.length() == pos.getIndex(); } }