Java Examples - Read File Content
The following example demonstrates using the readLine() method to read the content of the file test.log, where the content of test.log is:
Example www.example.com
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:
Example www.example.com nullOther Extensions
Java Examples