public class CopyCopyDemo {
public static void main(String[] args) {
FileInputStream fis=null;
FileOutputStream fos=null;
try{
fis=new FileInputStream("e:\\1\\1.txt");
fos=new FileOutputStream("f:\\1.txt");
int len=0;
while((len=fis.read())!=-1){
fos.write(len);
}
}
catch(IOException ie){
ie.printStackTrace();
throw new RuntimeException("出错了");
}finally{
try{
if(fis!=null)
fis.close();
}catch(IOException ie){
throw new RuntimeException("没有关闭");
}finally{
try{
if (fos!=null)
fos.close();
}catch(IOException ie){
throw new RuntimeException("没关闭");
}
}
}
}
}
|
|