Java examples for Language Basics:String
Breaking a String into Words
import java.util.StringTokenizer; public class Main { public static void main(String[] argv) { String aString = "word1 word2 word3"; StringTokenizer parser = new StringTokenizer(aString); while (parser.hasMoreTokens()) { System.out.println(parser.nextToken()); }/* w w w . j a va 2s .c o m*/ } }