Here is a solution using Apache Commons.IO FileUtils, and the appropriate methods on File objects.
for (File f : FileUtils.listFilesAndDirs(new File('/some/path'), TrueFileFilter.TRUE, TrueFileFilter.TRUE)) {
if (!f.setReadable(true, false)) {
throw new IOException(String.format("Failed to setReadable for all on %s", f));
}
if (!f.setWritable(true, false)) {
throw new IOException(String.format("Failed to setWritable for all on %s", f));
}
if (!f.setExecutable(true, false)) {
throw new IOException(String.format("Failed to setExecutable for all on %s", f));
}
}
This is the equivalent of chmod -R 0777 /some/path
. Adjust the set{Read,Writ,Execut}able
calls to implement other modes. (I'll happily update this answer if someone posts appropriate code to do this.)