The StringTokenizer class in java.util package has been deprecated as of Java 1.4. Sun recommends the use of String.split method instead of java.util.StringTokenizer class.
For eg:
StringTokenizer strTokens = new StringTokenizer("Token String"); while (strTokens.hasMoreTokens()) { System.out.println(strTokens.nextToken()); }
Can be replaces with the following code.
String[] splittedSting = "Token Sting".split("\\s"); for (int x=0; x<splittedSting.length; x++) { System.out.println(splittedSting[x]); }
If you enjoyed this post, make sure you subscribe to my RSS feed!



























Could it be a good idea to replace fast and optimized code “StringTokenizer” with a 3 times slower String.split() ? String.split is using Pattern and a Matcher from regex. From this point of view you trade ashes for gold..