Java File.setWritable(boolean writable, boolean ownerOnly)

Syntax

File.setWritable(boolean writable, boolean ownerOnly) has the following syntax.

public boolean setWritable(boolean writable,   boolean ownerOnly)

Example

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


/*from w  w  w. j  a v a  2s . c  o  m*/

import java.io.File;

public class Main {
  public static void main(String[] args) {
    File f = new File("C:/test.txt");

    boolean bool = f.setWritable(true, false);

    System.out.println( bool);

    bool = f.canWrite();

    System.out.print(bool);

  }
}

The code above generates the following result.