InputOutputDemo.java Source code

Java tutorial

Introduction

Here is the source code for InputOutputDemo.java

Source

import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;

public class InputOutputDemo {

    public static void main(String[] a) throws Exception {
        PrintWriter pwr = new PrintWriter(new FileWriter("java2s.txt"));
        pwr.print(4711);
        pwr.print(' ');
        pwr.print("Java Source and Support at www.java2s.com");
        pwr.close();

        StreamTokenizer stok = new StreamTokenizer(new FileReader("java2s.txt"));
        int tok = stok.nextToken();
        while (tok != StreamTokenizer.TT_EOF) {
            System.out.println(stok.sval);
            tok = stok.nextToken();
        }
    }
}