学习总结
字节流与字符流基本操作
一.IO操作主要流程
(1)使用File类打开一个文件。
(2)通过字节流或字符流的子类指定输出的位置。
(3)进行读/写操作。
(4)关闭输入/输出。
二、字节流
(1)字节输出流:
public FileOutputStream(File file) throws FileNotFoundException
(2)文件不存在会自动创建
(3)追加新的内容用
public FileOutputStream(File file,boolean append) throws FileNotFoundException
(4)使用\r\n增加换行
(5)字节输出流
public File InputStream(File file) throws FileNotFoundException
三、字符流
(1)字符输出流Writer
(2)使用FileWriter追加文件内容
public Writer(File file,boolean append) throws IOException
(3)字符输入流
public FileReader(File file) throws FileNotFoundException
(4)使用循环的方式读取内容
(5)字节流与字符流的区别
(6)文件复制
四、转换流
(1)
OutputStreamWriter类与InputStreamReader
五、内存操作流
(1)字节内存流与字符内存流
(2)创建临时文件用内存操作流最合适。
六、管道流
(1)管道输入流和管道输出流
(2)运用Connection()方法将两个线程管道连接在一起。
原文:https://www.cnblogs.com/1211li/p/11784338.html