Java Utililty Methods File Mod Change

List of utility methods to do File Mod Change

Description

The list of methods to do File Mod Change are organized into topic(s).

Method

voidchmod(@Nonnull File file, int mode)
chmod
final Path path = file.toPath();
if (!Files.isSymbolicLink(path)) {
    Files.setPosixFilePermissions(path, getPermissions(mode));
voidChmod(boolean recursive, String permission, String directoryFile)
Change permission of files and directories
String osName = System.getProperty("os.name");
String command = "chmod";
if (recursive) {
    command += " -R";
if (osName.startsWith("Mac OS")) {
    Runtime.getRuntime().exec(command + " " + permission + " " + directoryFile);
} else if (osName.startsWith("Windows")) {
...
intchmod(File file, int mode)
chmod
return chmod(file.getName(), mode);
voidchmod(File file, String mode)
chmod
Runtime.getRuntime().exec(new String[] { "chmod", mode, file.getAbsolutePath() });
voidchmod(final int mode, final File path)
chmod
path.setReadable(false, false );
path.setWritable(false, false );
path.setExecutable(false, false );
path.setReadable((mode & 0400) == 0400, true );
path.setWritable((mode & 0200) == 0200, true );
if (path.isDirectory() || (mode & 0100) == 0100) {
    path.setExecutable(true, true );
if ((mode & 0044) == 0044) {
    path.setReadable(true, false );
if ((mode & 0011) == 0011) {
    path.setExecutable(true, false );
voidchmod(final String path, final String mode)
chmod
final String[] cmdarray = new String[] { "chmod", mode, path };
Runtime.getRuntime().exec(cmdarray, null, null);
intchmod(String filename, String perm)
Change the permissions on a filename.
String cmd = "chmod " + perm + " " + filename;
Process p = Runtime.getRuntime().exec(cmd, null);
return p.waitFor();
booleanchmodX(String filename)
chmod X
File f = new File(filename);
if (f.exists())
    return f.setExecutable(true);
return false;