import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
public class D4a {
FileInputStream input;
FileOutputStream output;
String h1;
String h2;
public void copy(String sc,String sb ) throws Exception {
File c1=new File(sc);
File c2=new File(sb);
if(!c2.exists()) {
c2.mkdir();
}
int I;
File[] g=c1.listFiles();
I=g.length;
for(int i=0;i<I;i++) {
if(!g[i].isDirectory()){
h1=g[i].toString();
h2=sb+"\\"+g[i].getName();
copyfile(h1,h2);
}
else{copy(g[i].getPath(),sb+"\\"+g[i].getName());}
}
}
public void copyfile(String inputs,String outputs) throws Exception {
input=new FileInputStream(inputs);
output=new FileOutputStream(outputs);
int n;
while((n=input.read())!=-1) {
output.write(n);
}
input.close();
output.close();
}
public static void main(String[] args) throws Exception {
new D4a().copy("D:\\zuoye\\wenjian","D:\\zuoye\\wenjianjia");
}
}