String Tokenizer in Java

// Demonstrate StringTokenizer. 
import java.util.StringTokenizer; 
class STDemo { 
static String in = "title=Java-Samples;" + 
"author=Emiley J;" + 
"publisher=java-samples.com;" + 
"copyright=2007;"; 
public static void main(String args[]) { 
StringTokenizer st = new StringTokenizer(in, "=;"); 
while(st.hasMoreTokens()) { 
String key = st.nextToken(); 
String val = st.nextToken(); 
System.out.println(key + "\t" + val); 


}

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|