/** * Recursively copy files and directories. The target must not exist before this operation. * * @param aIn the source. * @param aOut the target. * @throws IOException if something goes wrong. */ public static void copy(File aIn, File aOut, boolean aLink) throws IOException { if (aOut.exists()) { throw new IOException("Target ["+aOut+"] already exists"); } if (aIn.isDirectory()) { aOut.mkdirs(); for (File child : aIn.listFiles()) { copy(child, new File(aOut, child.getName()), aLink); } } else { if (aLink) { createSymbolicLink(aIn, aOut); } else { copyFile(aIn, aOut); } } }
/** * Recursively copy files and directories. The target must not exist before this operation. * * @param aIn the source. * @param aOut the target. * @throws IOException if something goes wrong. */ public static void copy(File aIn, File aOut, boolean aLink) throws IOException { if (aOut.exists()) { throw new IOException("Target ["+aOut+"] already exists"); } if (aIn.isDirectory()) { aOut.mkdirs(); for (File child : aIn.listFiles()) { copy(child, new File(aOut, child.getName()), aLink); } } else { if (aLink) { createSymbolicLink(aIn, aOut); } else { copyFile(aIn, aOut); } } }