Here you can find the source of copyDirectory(File srcPath, File dstPath)
public static void copyDirectory(File srcPath, File dstPath) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { public static void copyDirectory(File srcPath, File dstPath) throws IOException { if (srcPath.isDirectory()) { if (!dstPath.exists()) { dstPath.mkdirs();/*from w w w. j a va 2 s . c o m*/ } String files[] = srcPath.list(); for (int i = 0; i < files.length; i++) { copyDirectory(new File(srcPath, files[i]), new File(dstPath, files[i])); } } else { if (srcPath.exists()) { InputStream in = new FileInputStream(srcPath); OutputStream out = new FileOutputStream(dstPath); byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } in.close(); out.close(); } } } }