读写文件

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * @author Administrator
 * @version v1.0, 2011-5-15
 */
public class Test2 {

    /**
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        // TODO Auto-generated method stub
        File f=new File("e:/修改好数据.rar");
       
        InputStream inputStream=new BufferedInputStream(new FileInputStream(f)) ;
        OutputStream out = new BufferedOutputStream(new FileOutputStream(new File("c:/a.rar")));
        byte[] b=new byte[1024*1024];
        long inslength=0;
        int r=0;
        long a=System.currentTimeMillis();
        int m=1;
        while((r=inputStream.read(b))!=-1){
            System.out.println(m+":1111111111111..."+r);
            out.write(b);
            inslength+=r;
            m++;
        }
        System.out.println(System.currentTimeMillis()-a);
        System.out.println(inslength);
      
        while((r=inputStream.read(b))!=-1){
            System.out.println("222222222..."+r);
        }
       
        inputStream.close();
        out.close();
    }

}

你可能感兴趣的:(java,C++,c,F#,C#)