FileUtil { public static void copyDir(File srcDir, File destDir) throws IOException, InterruptedException { if (!Os.isMicrosoftWindows()) { String cmd = "cp -R '"+srcDir.getAbsolutePath()+"' '"+destDir.getAbsolutePath()+"'"; Process proc = Runtime.getRuntime().exec(cmd); proc.waitFor(); if (proc.exitValue() == 0) return; } FileUtils.copyDirectory(srcDir, destDir); }  static void setFilePermissionsTo700(File file); static void setFilePermissionsTo600(File file); static void moveDir(File srcDir, File destDir); static void copyDir(File srcDir, File destDir); @Beta static Maybe<String> getFilePermissions(File file); @Beta static void copyTo(InputStream in, File dest); static void deleteDirectory(final File file);  }
@Test(groups="Integration") public void testCopyDir() throws Exception { File destParent = Files.createTempDir(); try { Files.write("abc", new File(dir, "afile"), Charsets.UTF_8); File destDir = new File(destParent, "dest"); FileUtil.copyDir(dir, destDir); assertEquals(Files.readLines(new File(destDir, "afile"), Charsets.UTF_8), ImmutableList.of("abc")); assertEquals(Files.readLines(new File(dir, "afile"), Charsets.UTF_8), ImmutableList.of("abc")); } finally { if (destParent != null) Os.deleteRecursively(destParent); } }