Here you can find the source of isNumber(String str)
Parameter | Description |
---|---|
str | a parameter |
public static boolean isNumber(String str)
//package com.java2s; /**/*from w ww. j av a 2 s . com*/ * * Methods Descrip:Converts a line of text into an array of lower case words * using a BreakIterator.wordInstance(). * <p> * * This method is under the Jive Open Source Software License and was * written by Mark Imbriaco. * * @param text * a String of text to convert into an array of words * @return text broken up into an array of words. * */ import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { /** * * Methods Descrip: * * @param str * @return * */ public static boolean isNumber(String str) { boolean flag = false; if (str == null || str.equals("")) { return false; } Pattern p = Pattern.compile("[0-9]*"); ; Matcher m = p.matcher(str); ; flag = m.matches(); return flag; } }