package com.knock.io;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.junit.Test;
/**
* @date 160802pm 测试文件夹拷贝
* */
public class KdCopyDirectory {
String srcPath = "D:/test/school";
String destPath = "E:/test/school";
File src = new File(srcPath);
File dest = null;
InputStream is = null;
OutputStream os = null;
@Test
public void test() {
if(src.isDirectory()){//如果src为目录,那么我们在desc下也创建一个和src同名的文件夹
dest = new File(destPath,src.getName());
}
copyDir(src, dest);
}
public void copyDir(File src,File dest) {
if(src.isFile()){
Utils.copyFile(src, dest);
}else if(src.isDirectory()){
dest.mkdirs();
for(File f:src.listFiles()){
copyDir(f, new File(dest,f.getName()));//mark
}
}
}
}