java使用字符缓冲流读取文件

mac2024-12-09  27

BufferedReader更快、更好的读取文件,对中文友好 import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class demo01 { public static void main(String[] args) throws IOException { String str1="C:\\Users\\Administrator\\Desktop\\test.txt"; BufferedReader bufferedReader = new BufferedReader(new FileReader(str1)); String line; while ((line=bufferedReader.readLine())!=null){ System.out.println(line); } bufferedReader.close(); } }

 

最新回复(0)