public static boolean isNumber(String str)
{
boolean isTrue = false;
if (!str.contains(" "))
{
StringBuffer sb = new StringBuffer("");
for (int i = 1; i <= str.length(); i++)
{
sb.append("[0-9]");
}
Pattern pat = Pattern.compile(sb.toString());
Matcher matcher = pat.matcher(str);
if (matcher.matches())
{
isTrue = true;
}
}
return isTrue;
}
{
boolean isTrue = false;
if (!str.contains(" "))
{
StringBuffer sb = new StringBuffer("");
for (int i = 1; i <= str.length(); i++)
{
sb.append("[0-9]");
}
Pattern pat = Pattern.compile(sb.toString());
Matcher matcher = pat.matcher(str);
if (matcher.matches())
{
isTrue = true;
}
}
return isTrue;
}