io操作小结

来源:互联网 发布:淘宝卖家中心在哪 编辑:程序博客网 时间:2024/06/10 11:10
io 操作1.按流的方向分为:输入流(InputStream  Reader )和输出流(OutputStream   Writer)

2.按流的数据单位不同分为:字节流(InputStream   OutputStream  )和字符流(Reader Writer )


缓冲流要套接在相应的节点流之上,提高了读写的效率。  

字节流转字符流:InputStreamReader   System.in:系统提供录入,输入的是字节流
转换流:InputStreamReader ins = new InputStreamReader(System.in);
建立对象ins的字符缓冲流
字符缓冲流:BufferedReader buf = new BufferedReader(ins);



ByteArrayOutputStream  字节数组输出流   此为获取一个字节数组方法,返回字节数组
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream 数据流       按数据类型写入外部设备  数据流是字节流
DataOutputStream dos = new DataOutputStream(bos);//对象bos提供 字节数组输出流

关闭流用close();

0 0
原创粉丝点击