Does a Split method exist in Java, if so, do you know where to get it (like what package, or something)?
Thanks
:)
Printable View
Does a Split method exist in Java, if so, do you know where to get it (like what package, or something)?
Thanks
:)
hey crptcblade,
define a split method?
Manoj
yeah, umm, nevermind:rolleyes:. I did the nitty-gritty and wrote my own:)
Thanks
:D
crptcblade,
It actually does have something simliar.
It's in the java.util package.
I haven't used it but I believe the syntax is:
It usesCode:String strToSplit = "This is a sentence.";
StringTokenizer tokens = new StringTokenizer(strToSplit);
.countTokens() to determine the number of tokens returned.
.hasMoreTokens() if there are more tokens left.
.nextToken() to move to the next token.
I'm not sure of the other methods, I just made a quick glance through my Java book.
Hey thanks. Does that only split at spaces? It looks that way huh? I wrote up a little class, it's not great, but it splits at any delimiter (I think ;) ) and returns an array of Strings. Haven't fully tested it yet, though.
:)
The default is " \n\t\r".
Space, newline, tab and carriage return.