关于FileInputStream,FileReader和FileOutputStream,FileWriter区别问题

FileInputStream是字节型文件输入流,而FileReader是字符型文件读取流。区别就在于,在流的传输过程中一个是以字节为单位,另一个是以字符(可以为一个字节,或多个字节)为单位。

读:

FileInputStream---》new FileInputStream(new File(path+name)).read(new byte[length]);  new String(byte)   就能得到相应的字符串。

FileReader---->     String str=new BufferedReader(new FileReader(new File())).nextline()!=null;  得到的str就是对应的输出字符串。

写:

FileOutputStream--》new FileOutputStream(new File(path+name)).write(byte[]);

FileWriter-->     new FileWriter(new File(path+name)).write(string);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值