Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.StreamTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader in = null;
        in = new BufferedReader(new FileReader("fileeditor.txt"));
        StreamTokenizer st = new StreamTokenizer(in);
        st.eolIsSignificant(false);
        // remove comment handling
        st.slashSlashComments(false);
        st.slashStarComments(false);

        while (st.nextToken() != StreamTokenizer.TT_EOF) {
            if (st.ttype == StreamTokenizer.TT_NUMBER) {
                // the default is to treat numbers differently than words
                // also the numbers are doubles
                System.out.println((int) st.nval);
            } else {
                System.out.println(st.sval);
            }
        }
    }
}