package com.mstf.scme.test;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class Copy {
public static void main(String[] args) {
FileInputStream fis=null;
FileOutputStream fos=null;
try {
fis=new FileInputStream("F://123.rar");
fos=new FileOutputStream("F://111.rar");
int data=0;
long bTime=System.currentTimeMillis();
while ((data=fis.read())!=-1) {
fos.write(data);
}
long eTime=System.currentTimeMillis();
long Time=(eTime-bTime);
System.out.println("完成文件的拷贝,耗时"+Time+"毫秒");
} catch (FileNotFoundException e) {
// TODO: handle exception
e.printStackTrace();
}catch (IOException e) {
// TODO: handle exception
e.printStackTrace();
}
finally{
try {
if (fis!=null) {
fis.close();
}if (fos!=null) {
fos.close();
}
} catch (Exception e2) {
// TODO: handle exception
e2.printStackTrace();
}
}
}
}
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class Copy {
public static void main(String[] args) {
FileInputStream fis=null;
FileOutputStream fos=null;
try {
fis=new FileInputStream("F://123.rar");
fos=new FileOutputStream("F://111.rar");
int data=0;
long bTime=System.currentTimeMillis();
while ((data=fis.read())!=-1) {
fos.write(data);
}
long eTime=System.currentTimeMillis();
long Time=(eTime-bTime);
System.out.println("完成文件的拷贝,耗时"+Time+"毫秒");
} catch (FileNotFoundException e) {
// TODO: handle exception
e.printStackTrace();
}catch (IOException e) {
// TODO: handle exception
e.printStackTrace();
}
finally{
try {
if (fis!=null) {
fis.close();
}if (fos!=null) {
fos.close();
}
} catch (Exception e2) {
// TODO: handle exception
e2.printStackTrace();
}
}
}
}