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
网友评论