Results 1 to 6 of 6

Thread: Split method?

  1. #1

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    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

  2. #2
    Lively Member
    Join Date
    Jan 2000
    Posts
    69

    define a split method

    hey crptcblade,


    define a split method?


    Manoj

  3. #3

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    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

  4. #4
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    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.
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  5. #5

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    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

  6. #6
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    The default is " \n\t\r".
    Space, newline, tab and carriage return.
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width