FileInputStream InputStreamReade

2018-06-03  本文已影响0人  橙姜

FileInputStreamFile  FileOutputStream按字节读写

InputStreamReader  OutputStreamWriter按字符读写

BufferedReader BufferedWriter按行读写

读取或输出文本一般用BufferedReader.readLine()和PrintWriter.println()方法;

PrintWriter和BufferedWriter同样提供可缓冲输出,但是PrintWriter可设置自动清除缓冲,不需要pw.flush();

PrintWriter pw = new PrintWriter(OutputStreamWirter(“d.txt”,”UTF-8”),true);//true表示自动清除缓冲

注意:①写时需要flush() ,PrintWriter可设定自动清除

②别忘了关闭流

https://blog.csdn.net/lykangjia/article/details/70159619?utm_source=itdadao&utm_medium=referral

上一篇 下一篇

猜你喜欢

热点阅读