import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.io.FileUtils;
public class Demo1 {
public static void filecopy(String source,String target) throws Exception{
InputStream in = new FileInputStream(source);
OutputStream out=new FileOutputStream(target);
byte[] buffer = new byte[1024];
int read;
while( (read =in.read(buffer))!=-1 ){
out.write(buffer, 0, read);
}
}
public static void main(String[] args) throws Exception {
String aa = "F:\\11\\a\\1.txt";
String bb = "f:\\11\\b\\2.txt";
//filecopy(aa, bb);
File f1 = new File(aa);
File f2 = new File(bb);
FileUtils.copyFile(f1, f2);//apache commons-io
}
}
Java文件拷贝
最新推荐文章于 2024-08-23 15:54:50 发布