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

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数组来装进去 而是直接读取和写 然后发现输出的结果比源文件小一半 这个是为什么呢

慕移动7208282
浏览 1097回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java