Change to executable, readable, writable

ReturnMethodSummary
booleansetExecutable(boolean executable)A convenience method to set the owner's execute permission for this abstract pathname.
booleansetExecutable(boolean executable, boolean ownerOnly)Sets the owner's or everybody's execute permission for this abstract pathname.
booleansetReadable(boolean readable)A convenience method to set the owner's read permission for this abstract pathname.
booleansetReadable(boolean readable, boolean ownerOnly)Sets the owner's or everybody's read permission for this abstract pathname.
booleansetReadOnly()Marks the file or directory named by this abstract pathname so that only read operations are allowed.
booleansetWritable(boolean writable)A convenience method to set the owner's write permission for this abstract pathname.
booleansetWritable(boolean writable, boolean ownerOnly)Sets the owner's or everybody's write permission for this abstract pathname.

import java.io.File;

public class Main {

  public static void main(String[] args) {
    File file = new File("c:/a.htm");
    file.setExecutable(true);
    file.setReadable(true);
    
  }
}

Mark file or directory Read Only


import java.io.File;

public class Main {
    public static void main(String[] args) {
        File file = new File("C:/data.dat");
        boolean blnMarked = file.setReadOnly();
        System.out.println("Was file marked read only ?: " + blnMarked);
        System.out.println("Is file writable ?: " + file.canWrite());
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.