UNB/ CS/ David Bremner/ teaching/ old/ cs1083/ java/ StreamTokenizerExample.java
import java.io.StreamTokenizer;
import java.io.StringReader;
import java.io.IOException;
import java.io.FileReader;
import java.io.FileInputStream;
import java.io.InputStream;
public class StreamTokenizerExample {
    public static void main(String args[]) throws IOException{

        StreamTokenizer st=new StreamTokenizer(new FileReader("table.dat"));
        int type=st.nextToken();

        while (type!= StreamTokenizer.TT_EOF) {
            switch(type){
            case StreamTokenizer.TT_WORD:
                System.out.println("word: "+st.sval);
                break;
            case StreamTokenizer.TT_NUMBER:
                System.out.println("number: "+st.nval);
                break;
            case '\'':
                System.out.println("quoted: "+st.sval);
                break;
            case ',':
                System.out.println("comma");
                break;
            default:
                System.out.println(st.toString());
            }
            type=st.nextToken();
        }

    }
}