我有这个文件:
➜ ✗ ll ltr /Users/eladb/WorkspaceQa/sdk-service/src/main/resources/convert_conditions.sh
-rwxrwxrwx 1 eladb eng 882B Jun 11 16:38 /Users/eladb/WorkspaceQa/sdk-service/src/main/resources/convert_conditions.sh
我尝试从java中读取它:
new FileInputStream(new File("/Users/eladb/WorkspaceQa/sdk-service/src/main/resources/convert_conditions.sh"));
但是我收到了错误:
java.security.AccessControlException: access denied ("java.io.FilePermission" "/Users/eladb/WorkspaceQa/sdk-service/src/main/resources/convert_conditions.sh" "read")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) ~[?:1.8.0_91]
at java.security.AccessController.checkPermission(AccessController.java:884) ~[?:1.8.0_91]
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) ~[?:1.8.0_91]
at java.lang.SecurityManager.checkRead(SecurityManager.java:888) ~[?:1.8.0_91]
at java.io.FileInputStream.<init>(FileInputStream.java:127) ~[?:1.8.0_91]
为什么每个人都拥有该文件的读取权限?
答案 0 :(得分:0)
操作系统的文件权限与它无关。查看堆栈跟踪,或实际上是异常的Javadoc。此异常来自Java安全管理器,而不是操作系统。您是在安全管理器下运行的(为什么?)并且您还没有授予自己访问.policy文件中该文件的权限。