IO学习(十四)总结IO学习1-13
来源:互联网 发布:ubuntu邮箱服务器一键 编辑:程序博客网 时间:2024/06/05 15:01
在javaIO学习过程中,IO流数不胜数,各自的构造方法和常用方法也各有不同,尤其加入处理流,比如缓冲流,转换流以后,创建一个流类对象就显的特别复杂,下面就总结之前1-13种用到所有IO流的常用构造方法
1.File类
File file=new File("F:/Picture/test/test.txt");
具体方法不写了,IO学习2对File类的介绍比较详细了
2.FileInputStream类
InputStream is=new FileInputStream(file);
字节输入流
3.FileOutputStream类
OutputStream os=new FileOutStream(file);
字节输出流
4.BufferedInputStream类
InputStream is=new BufferedInputStream(new FileInputStream(file));
字节缓冲输入流,属于处理流
5.BufferedOutputStream类
OutputStream os=new BufferedOutputStream(new FileOutputStream(file));
字节缓冲输出流,属于处理流
序列化和反序列化
6.ObjectInputStream类
ObjectInputStream ois=new ObjectInputStream(new BufferedInputStream(new FileInputStream(file)));
反序列化:对象输入流
7.ObjectOutputStream类
ObjectOutputStream oos=new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
序列化:对象输出流
字节数组流
6.ByteArrayInputStream类
InputStream bis=new BufferedInputStream(new ByteArrayInputStream(destByte));
字节数组输入流
7.ByteArrayOutputStream类
ByteArrayOutputStream bos=new ByteArrayOutputStream();
由于输出流有新增方法,所以这里不可以使用多态
8.FileReader类
Reader re=new FileReader(file);
字符输入流
9.FileWriter类
Writer wr=new FileWriter(file);
字符输出流
10.BufferedReader类
BufferedReader br=new BufferedReader(new FileReader(file));
字符缓冲输入流,因为有新的方法,所以不可使用多态
11.BufferedWriter类
BufferedWriter bw=new BufferedWriter(new FileWriter(file));
字符缓冲输出流,因为有新的方法,所以不可使用多态
特殊的转换流,从字节流转为字符流
12.InputStreamReader类
BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(file)));
13.OutputStreamWriter类
BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));
14.ByteArrayInputStream类
InputStream bis=new BufferedInputStream(new ByteArrayInputStream(destByte));
字节数组输入流
15.ByteArrayOutputStream类
ByteArrayOutputStream bos=new ByteArrayOutputStream();
由于输出流有新增方法,所以这里不可以使用多态
除了这些IO流类创建对象,文件的拷贝也进行了很多次,
1.用字节流FileInputStream,FileOutputStream
2,字符流进行纯文本的拷贝,FileReader,FileWriter
3.文件夹的拷贝,一个递归算法不断进入文件夹的内部,也涵盖了文件的拷贝
4.利用字节数组流作为中转进行文件的拷贝 ByteArrayOutputStream,ByteArrayInputStream
- IO学习(十四)总结IO学习1-13
- Java学习笔记(十四)--IO流
- 高级IO学习总结1
- Java io学习总结
- IO流学习总结
- java.io学习总结
- JAVA IO 学习总结
- io学习小总结
- JAVA IO 学习总结
- JAVA IO学习总结
- JAVA IO 学习总结
- IO流学习总结
- IO流学习总结
- java.io学习总结
- java IO学习总结
- IO学习总结
- IO流学习总结
- java.io学习总结
- 深入浅出Win32多线程程序设计
- 上传ipa包时"Missing 64-bit support.Begining..."
- Scala学习笔记-伴生对象于孤立对象
- nyoj747蚂蚁的难题(三)
- [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
- IO学习(十四)总结IO学习1-13
- adb用不了,error: unknown host service的解决办法 (360的360MobileLoader.exe,QQ的tadb.exe)
- 记下今天
- 分别用自定义PopupWindow和自定义Dialog实现下拉菜单
- Extjs中的tree节点的操作
- leetcode 21--Merge Two Sorted Lists 链表 合并
- android - 如何在webview中调起拨号
- 读取配置文件,利用反射给类属性赋值,
- rabbitmq 笔记(自看)