trim()

The method trim() of String has the ability to remove 'white space'-characters from the beginning and end of the string (actually, it creates a new String, but you know what I mean). Is there a method that allows me to go to the next non-'white space' character in a string?
[285 byte] By [EvilBroa] at [2007-11-26 19:25:35]
# 1

> The method trim() of String has the ability to remove

> 'white space'-characters from the beginning and end

> of the string (actually, it creates a new String, but

> you know what I mean). Is there a method that allows

> me to go to the next non-'white space' character in

> a string?

indexOf method

p_epia at 2007-7-9 21:49:57 > top of Java-index,Java Essentials,New To Java...
# 2
yes indexOf().....ll solve ur problem
brijesha at 2007-7-9 21:49:57 > top of Java-index,Java Essentials,New To Java...
# 3
Another option is regexp.Kaj
kajbja at 2007-7-9 21:49:57 > top of Java-index,Java Essentials,New To Java...
# 4
How does indexOf help me find the first non-'white space'-character? (Note that I'm not looking for a specific character, but for any character that is not 'white space'.)
EvilBroa at 2007-7-9 21:49:57 > top of Java-index,Java Essentials,New To Java...
# 5

> How does indexOf help me find the first non-'white

> space'-character? (Note that I'm not looking for a

> specific character, but for any character that is not

> 'white space'.)

you use indexOf to find list of the 'white space' index at that string

based on that result, you can find the list of non 'white space' index

or you can use java.util.regex package for another alternative

p_epia at 2007-7-9 21:49:57 > top of Java-index,Java Essentials,New To Java...
# 6
If you are trying to split a string at the first whitespace character and then get the character, try:String[] parts = string.split(" ", 2)then you can always do Char firstChar = parts[1].charat(0);Message was edited by: PMBain
PMBaina at 2007-7-9 21:49:57 > top of Java-index,Java Essentials,New To Java...