Java File Attribute ensureFileIsExecutable(String filename)

Here you can find the source of ensureFileIsExecutable(String filename)

Description

Ensure that given file, if it exists, is executable

License

Apache License

Parameter

Parameter Description
filename a parameter

Declaration

public static boolean ensureFileIsExecutable(String filename) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.File;

public class Main {
    /**/*from  ww  w  .ja  va 2  s  .c  o  m*/
     * Ensure that given file, if it exists, is executable
     *
     * @param filename
     */
    public static boolean ensureFileIsExecutable(String filename) {
        File file = new File(filename);
        if (file.exists()) {
            if (file.canExecute()) {
                return true;
            }
            return file.setExecutable(true);
        }
        return false;
    }
}

Related

  1. checkIfExecutableIsInPATH(final String executableName)
  2. doesExecutableExist(String executablePath)
  3. ensureExecutable(final File file)
  4. ensureExecutable(IPath path)
  5. fileExecute(String path)
  6. findInPath(String executable, String path, String pathSeparator)
  7. findJavaCompilerExecutableInDir(File dir)
  8. findJavaExecutable(File vmInstallLocation)