The following example demonstrates using the readLine() method to read the content of the file test.log, where the content of the test.log file is:
菜鸟教程www.runoob.com
/* author by runoob.com Main.java */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 above code runs The output result is:
菜鸟教程www.runoob.comnull
The above is the Java example - reading the content of the file. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!