Here you can find the source of copyDir(File source, File destination)
public static boolean copyDir(File source, File destination)
//package com.java2s; 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 boolean copyDir(File source, File destination) { InputStream in = null;/*from ww w . ja v a2 s . com*/ OutputStream out = null; label222: try { if (source.isDirectory()) { if (!destination.exists()) { destination.mkdir(); } String[] children = source.list(); if (children != null) { for (int i = 0; i < children.length; i++) { copyDir(new File(source, children[i]), new File( destination, children[i])); } break label222; } } else { in = new FileInputStream(source); out = new FileOutputStream(destination); byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } } } catch (Exception e) { e.printStackTrace(); return false; } finally { try { if (in != null) { in.close(); } } catch (IOException e) { e.printStackTrace(); } try { if (out != null) { out.close(); } } catch (IOException e) { e.printStackTrace(); } } return true; } }