/** * Copy an entire directory tree. * * @param fromDirName from this directory (do nothing if not exist) * @param toDirName to this directory (will create if not exist) * @throws java.io.IOException on io error */ static public void copyDirTree(String fromDirName, String toDirName) throws IOException { File fromDir = new File(fromDirName); File toDir = new File(toDirName); if (!fromDir.exists()) return; if (!toDir.exists()) toDir.mkdirs(); for (File f : fromDir.listFiles()) { if (f.isDirectory()) copyDirTree(f.getAbsolutePath(), toDir.getAbsolutePath() + "/" + f.getName()); else copyFile(f.getAbsolutePath(), toDir.getAbsolutePath() + "/" + f.getName()); } }
/** * Copy an entire directory tree. * * @param fromDirName from this directory (do nothing if not exist) * @param toDirName to this directory (will create if not exist) * @throws java.io.IOException on io error */ static public void copyDirTree(String fromDirName, String toDirName) throws IOException { File fromDir = new File(fromDirName); File toDir = new File(toDirName); if (!fromDir.exists()) return; if (!toDir.exists()) { if (!toDir.mkdirs()) { throw new IOException("Could not create directory: " + toDir); } } File[] files = fromDir.listFiles(); if (files != null) for (File f : files) { if (f.isDirectory()) copyDirTree(f.getAbsolutePath(), toDir.getAbsolutePath() + "/" + f.getName()); else copyFile(f.getAbsolutePath(), toDir.getAbsolutePath() + "/" + f.getName()); } }
/** * Copy an entire directory tree. * * @param fromDirName from this directory (do nothing if not exist) * @param toDirName to this directory (will create if not exist) * @throws java.io.IOException on io error */ static public void copyDirTree(String fromDirName, String toDirName) throws IOException { File fromDir = new File(fromDirName); File toDir = new File(toDirName); if (!fromDir.exists()) return; if (!toDir.exists()) { if (!toDir.mkdirs()) { throw new IOException("Could not create directory: " + toDir); } } File[] files = fromDir.listFiles(); if (files != null) for (File f : files) { if (f.isDirectory()) copyDirTree(f.getAbsolutePath(), toDir.getAbsolutePath() + "/" + f.getName()); else copyFile(f.getAbsolutePath(), toDir.getAbsolutePath() + "/" + f.getName()); } }