Created
February 26, 2014 14:13
-
-
Save joseporiol/9230135 to your computer and use it in GitHub Desktop.
String tokenizer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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