private static void doCopy(File src, File dest, boolean overwrite, boolean copyContentOnly) throws IOException {
        if ((src == null) || (dest == null)) {
            throw new NullArgumentException("src or dest");
        }
        if (!src.exists()) {
            return;
        }
        if (src.isFile()) {
            if (dest.isDirectory()) {
                File newFile = new File(dest.getAbsolutePath() + File.separator + src.getName());
                copyFileToFile(src, newFile, overwrite);
            } else {
                copyFileToFile(src, dest, overwrite);
            }
        } else {
            if (dest.isFile()) {
                throw new IOException(
                        "Cannot copy directory into file: " + src.getAbsolutePath() + " -> " + dest.getAbsolutePath());
            } else {
                File dir;
                if (!copyContentOnly) {
                    dir = new File(dest.getAbsolutePath() + File.separator + src.getName());
                } else {
                    dir = dest;
                }
                dir.mkdirs();

                for (File child : src.listFiles()) {
                    copy(child, dir, overwrite);
                }
            }
        }
    }