I am trying to check the resolution of a given file using the following code snippet.
public static void main(String[] args) { try{ FilePermission fp = new FilePermission("E:/test.txt", "read"); AccessController.checkPermission(fp); System.out.println("Ok to open socket"); } catch (AccessControlException ace) { System.out.println(ace); }
So when I run it, it gives me the following exception:
java.security.AccessControlException: access denied ("java.io.FilePermission" "E:/test.txt" "read")
All rights are allowed on the file, but it throws me access to the thrown exception.
source share