Java IO Tutorial - Java File.setExecutable(boolean executable, boolean ownerOnly)








Syntax

File.setExecutable(boolean executable, boolean ownerOnly) has the following syntax.

public boolean setExecutable(boolean executable,   boolean ownerOnly)

Example

In the following code shows how to use File.setExecutable(boolean executable, boolean ownerOnly) method.

/*ww  w  . j av a 2s  . c o  m*/
import java.io.File;

public class Main {
  public static void main(String[] args) {

    File f = new File("test.txt");

    // set executable()
    boolean bool = f.setExecutable(true, true);

    System.out.println("setExecutable() succeeded?: " + bool);

    // can execute
    bool = f.canExecute();

    System.out.print("Can execute?: " + bool);

  }
}

The code above generates the following result.