Source of Words.java


  1: /* 
  2:  * Copyright (c) 1999-2002, Xiaoping Jia.  
  3:  * All Rights Reserved. 
  4:  */
  5: 
  6: import  java.io.*;
  7: import  java.util.*;
  8: 
  9: /**
 10:  *  This program breaks the input text into words. 
 11:  */
 12: public class Words {
 13: 
 14:   public static void main(String[] args) {
 15:     BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
 16:     try {
 17:       String line, word;
 18:       String delim = " \t\n.,:;?!-/()[]\"\'";  // spaces and punctuations
 19:       while((line =  in.readLine()) != null) {
 20:         StringTokenizer st = new StringTokenizer(line, delim);
 21:         while(st.hasMoreTokens()) {
 22:           System.out.println(st.nextToken());
 23:         }
 24:       }
 25:     }  catch(IOException e) {}
 26:   }
 27: 
 28: }