Skip to content

Instantly share code, notes, and snippets.

@joseporiol
Created February 26, 2014 14:13
Show Gist options
  • Save joseporiol/9230135 to your computer and use it in GitHub Desktop.
Save joseporiol/9230135 to your computer and use it in GitHub Desktop.
String tokenizer
import java.util.StringTokenizer;
public class StringTokenizer {
public static void main(String[] args) {
String str = "This is String , split by StringTokenizer, created by mkyong";
StringTokenizer st = new StringTokenizer(str);
System.out.println("---- Split by space ------");
while (st.hasMoreElements()) {
System.out.println(st.nextElement());
}
System.out.println("---- Split by comma ',' ------");
StringTokenizer st2 = new StringTokenizer(str, ",");
while (st2.hasMoreElements()) {
System.out.println(st2.nextElement());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment