public static void copyDirectory(File src, File dest) throws IOException {
File newFile = new File(dest, src.getName());
newFile.mkdir();
File[] file1 = src.listFiles();
for (File file : file1) {
if (file.isFile()) {
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
BufferedOutputStream bos = new BufferedOutputStream(
new FileOutputStream(new File(newFile,file.getName())));
int b;
while ((b = bis.read()) != -1) {
bos.write(b);
}
bis.close();
bos.close();
}else{
copyDirectory(file, newFile);
}
}
}