Here you can find the source of copyDirectory(File inputFolder, File outputFolder)
public static void copyDirectory(File inputFolder, File outputFolder) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class Main { public static void copyDirectory(File inputFolder, File outputFolder) throws IOException { outputFolder.getParentFile().mkdirs(); for (File innerFile : inputFolder.listFiles()) { if (innerFile.isDirectory()) { copyDirectory(innerFile, new File(outputFolder.getCanonicalPath() + "/" + innerFile.getName())); }//from www .java 2 s. co m if (innerFile.isFile()) { copyFile(innerFile, new File(outputFolder.getCanonicalPath() + "/" + innerFile.getName())); } } } public static void copyFile(File inputFile, File outputFile) throws IOException { outputFile.getParentFile().mkdirs(); FileReader in = new FileReader(inputFile); FileWriter out = new FileWriter(outputFile); int c; while ((c = in.read()) != -1) out.write(c); in.close(); out.close(); } }