文件字节流的复制

import java.io.*;
public class FileCopy{
 public static void main(String[] args){
  FileInputStream fis=null;
  FileOutputStream fos=null;
  int c;
  try{
   fis = new FileInputStream("c://t1.dat");
   fos = new FileOutputStream("d://t2.dat");
   while((c=fis.read())!=-1)
    fos.write(c);
  }catch(FileNotFoundException e1){
   System.out.println(e1); 
  }
  catch(IOException e2){
   System.out.println(e2);
  }
  finally{
   try{
    if(fis!=null)
     fis.close();
    if(fos!=null)
     fos.close();
   }catch(IOException e3){
    System.out.println(e3);
   }
  }
 
 }
}

你可能感兴趣的:(Java)