Easy Tutorial
❮ Exception Chain Number Xxxvalue ❯

Java Example - Reading File Content

Java Examples

The following example demonstrates how to read the content of the file test.log using the readLine() method, where the content of test.log is:

tutorialpro.org
www.tutorialpro.org

The Java code is as follows:

Main.java File

import java.io.*;

public class Main {
    public static void main(String[] args)  {
        try {
            BufferedReader in = new BufferedReader(new FileReader("test.log"));
            String str;
            while ((str = in.readLine()) != null) {
                System.out.println(str);
            }
            System.out.println(str);
        } catch (IOException e) {
        }
    }
}

The output of the above code is:

tutorialpro.org
www.tutorialpro.org
null

Java Examples

❮ Exception Chain Number Xxxvalue ❯