Java 实例 - 读取文件内容
使用 readLine() 方法来读取文件 test.log 内容,其中 test.log 文件内容为:
小鸟启蒙 www.facesoho.com
java 代码如下:
Main.java 文件
import java.io.*;
public class Main {
public static void main(String[] args) {
try {
BufferedReader in = new BufferedReader(new FileReader("facesoho.txt"));
String str;
while ((str = in.readLine()) != null) {
System.out.println(str);
}
System.out.println(str);
} catch (IOException e) {}
}
}
以上代码运行输出结果为:
小鸟启蒙 www.facesoho.com null
尊贵的董事大人
英文标题不为空时 视为本栏投稿
需要关键字 描述 英文标题