Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.FileReader;
import java.io.IOException;
import java.io.LineNumberReader;

public class Main {
    public static void main(String[] args) throws IOException {

        int i;

        // create new reader
        FileReader fr = new FileReader("C:/test.txt");
        LineNumberReader lnr = new LineNumberReader(fr);

        while ((i = lnr.read()) != -1) {
            // converts int to char
            char c = (char) i;

            // prints character
            System.out.println(c);
        }
        lnr.close();
    }
}