Is it executable, readable or writable

ReturnMethodSummary
booleancanExecute()Tests whether the application can execute the file denoted by this abstract pathname.
booleancanRead()Tests whether the application can read the file denoted by this abstract pathname.
booleancanWrite()Tests whether the application can modify the file denoted by this abstract pathname.

import java.io.File;

public class Main {

  public static void main(String[] args) {

    File parent = new File("c:/aFolder");
    File aFile = new File(parent, "aFile.txt");
    
    System.out.println(aFile.canExecute());
    System.out.println(aFile.canRead());
    System.out.println(aFile.canWrite());
  }
}

The output:


false
false
false
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.