Results 1 to 4 of 4

Thread: [done] Split() in Java?

  1. #1

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    [done] Split() in Java?

    Hi folks, is there any Split() function in Java? The function should split up strings by a specified token and put each part in a string array. Thanks.
    Last edited by Fox; Feb 12th, 2003 at 12:48 PM.

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    Code:
    String toSplit = "Hello,World,!";
    String split[] = toSplit.split(",");
    		
    for (int cnt = 0; cnt < split.length; cnt++)
    {
        System.out.println(split[cnt]);
    }

  3. #3
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    You could also go with a StringTokenizer object.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  4. #4

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Oh nice, thanks both!

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