Check number for spaces

Is there an easy way to check if a string has spaces in it.I need to check if a number held in a string has spaces or not.Number fornat1 234 567,00Thank youLeo
[201 byte] By [leofoxa] at [2007-10-3 3:02:11]
# 1

I'm sure there are 100 better ways to do it, but this workd lol

String s = "0201 530821";

if ( s.length() != s.replaceAll( " ", "" ).length() )

{

System.out.println( "you've got spaces" );

}

Norweeda at 2007-7-14 20:51:55 > top of Java-index,Java Essentials,New To Java...
# 2
You know what's a MUCH better wayLOLif ( s.contains( " " ) ){System.out.println( "you've got spaces" );}
Norweeda at 2007-7-14 20:51:55 > top of Java-index,Java Essentials,New To Java...
# 3

If you want to strip out the spaces, having found you have some then

someting like this, (code from java tutorial somewhere but I do not rememebr where)

String onlynums = new String();

for (int i = 0; i < mystring.length(); i++){

if (mystring.charAt(i) <='9' && mystring.charAt(i) >='0') {

onlynums += mystring.substring(i, i+1);

}

}

nerak99a at 2007-7-14 20:51:55 > top of Java-index,Java Essentials,New To Java...