title: How to check file permissions in Java (OS independently)
body: <p>I have the following snippet of code:</p>
  
  <pre><code>public class ExampleClass {
  
  public static void main(String[] args) throws FileNotFoundException {
      String filePath = args[0];
      File file = new File(filePath);
  
      if (!file.exists())
          throw new FileNotFoundException();
  
      if (file.canWrite())
          System.out.println(file.getAbsolutePath() + ": CAN WRITE!!!");
      else
          System.out.println(file.getAbsolutePath() + ": CANNOT WRITE!!!!!");
  
      if (file.canRead())
          System.out.println(file.getAbsolutePath() + ": CAN READ!!!");
      else
          System.out.println(file.getAbsolutePath() + ": CANNOT READ!!!!!");
  
      if (file.canExecute())
          System.out.println(file.getAbsolutePath() + ": CAN EXECUTE!!!");
      else
          System.out.println(file.getAbsolutePath() + ": CANNOT EXECUTE!!!!!");
  }
  }
  </code></pre>
  
  <p>It works in Linux OS, but the problem is that it doesn't work in windows7. So the question is: Does anybody know a method to check privileges to a file in Java OS INDEPENDENTLY? </p>