WEB开发网
开发学院WEB开发Jsp Java拷贝文件 阅读

Java拷贝文件

 2008-01-05 09:21:12 来源:WEB开发网   
核心提示: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])
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();
   }
  }

Tags:Java 拷贝 文件

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接