为了账号安全,请及时绑定邮箱和手机立即绑定

麻烦大神来看一下我的代码 IO流的

麻烦大神来看一下我的代码 IO流的

慕移动7208282 2017-11-06 14:40:54
package com.imooc; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class FlieStreamDemo { public static void main(String[] args) { try { FileInputStream fis = new FileInputStream("D:\\Io\\000000.win32.dat0"); FileOutputStream fos = new FileOutputStream("D:\\Io\\000000.win32-new.dat0"); long before = System.currentTimeMillis(); int count = 0; while((fis.read())!=-1){ fos.write(fis.read()); count++; } fis.close(); fos.close(); System.out.println("成功输出"); System.out.println(System.currentTimeMillis()-before + "毫秒"); System.out.println("读取了" + count + "次"); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }我输出一个大小为30m的文件 没有用byte数组来装进去 而是直接读取和写 然后发现输出的结果比源文件小一半 这个是为什么呢
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 1094 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信