copy文件

package com.lomner.file;

import java.io.FileInputStream;
import java.io.FileOutputStream;

public class JCopyFile {
       public void copyFile(String oldPath,String newPath) throws Exception{
              FileInputStream fis = null;
              FileOutputStream fos = null;
              try{
                     int count = 0;
                     byte[] buffer = new byte[1024];
                     fis = new FileInputStream(oldPath);
                     fos = new FileOutputStream(newPath);
   
                     while((count = fis.read(buffer) )>0){
                         fos.write(buffer,0,count);
                     }
              }catch(Exception e){
                     throw e;
              }finally{
                     if(fos != null){
                          fos.close();
                     }
                     if(fis != null){
                          fis.close();
                     }
              }
       }
 
       public static void main(String[] args) throws Exception{
              JCopyFile file = new JCopyFile();
              file.copyFile("F:/1.xls", "F:/2.xls");
       }
}

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