Read file with StreamTokenizer : StreamTokenizer « File Input Output « Java






Read file with StreamTokenizer

 
import java.io.FileReader;
import java.io.Reader;
import java.io.StreamTokenizer;

public class StreamTokenizerExample {
  public static void main(String[] args) throws Exception {

    Reader r = new FileReader("in.txt");
    StreamTokenizer st = new StreamTokenizer(r);
    while (st.nextToken() != StreamTokenizer.TT_EOF) {
      System.out.println(st.sval);
    }
    r.close();
  }
}

   
  








Related examples in the same category

1.Create StreamTokenizer from BufferedReader
2.Create StreamTokenizer from FileReader
3.Extract Tokens with StreamTokenizer
4.Set whitespaceChars
5.Set eolIsSignificant
6.Deal with StreamTokenizer.TT_WORD, StreamTokenizer.TT_NUMBER
7.Using StreamTokenizer to count words and numbers in a file
8.Tokenizing Java Source Code
9.Stream Token