import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
public class FileReadExample {
public static void main(String[] args) {
try {
// 读取文件
File file = new File("file.txt");
FileInputStream fis = new FileInputStream(file);
InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
BufferedReader br = new BufferedReader(isr);
// 输出文件内容
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
// 关闭流
br.close();
isr.close();
fis.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}