|
-
Jul 28th, 2001, 08:24 AM
#1
Split method?
Does a Split method exist in Java, if so, do you know where to get it (like what package, or something)?
Thanks
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jul 28th, 2001, 08:38 AM
#2
Lively Member
define a split method
hey crptcblade,
define a split method?
Manoj
-
Jul 28th, 2001, 09:05 AM
#3
yeah, umm, nevermind . I did the nitty-gritty and wrote my own
Thanks
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jul 28th, 2001, 09:00 PM
#4
Fanatic Member
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:
Code:
String strToSplit = "This is a sentence.";
StringTokenizer tokens = new StringTokenizer(strToSplit);
It uses
.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.
-
Jul 28th, 2001, 09:15 PM
#5
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.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jul 29th, 2001, 06:57 PM
#6
Fanatic Member
The default is " \n\t\r".
Space, newline, tab and carriage return.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|