当前位置:雨林木风下载站 > 网页设计教程 > 详细页面

Java拷贝文件

Java拷贝文件

更新时间:2026-01-04 文章作者:未知 信息来源:网络 阅读次数:

import java.io.*;public class jCOPY public static void main(String args[]) try jCOPY ...
import java.io.*;

public class jCOPY {
   public static void main(String args[]){
     try {
       jCOPY j = new jCOPY(); j.CopyFile(new File(args[0]),new File(args[1]));
       }
     catch (Exception e) {
       e.printStackTrace();
       }
     }

   public void CopyFile(File in, File out) throws Exception {
     FileInputStream fis  = new FileInputStream(in);
     FileOutputStream fos = new FileOutputStream(out);
     byte[] buf = new byte[1024];
     int i = 0;
     while((i=fis.read(buf))!=-1) {
       fos.write(buf, 0, i);
       }
     fis.close();
     fos.close();
     }
   }

温馨提示:喜欢本站的话,请收藏一下本站!

本类教程下载

系统下载排行