AccessControlException:访问被拒绝为可读文件 [英] AccessControlException: access denied for a readable file

查看:200
本文介绍了AccessControlException:访问被拒绝为可读文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个文件:

➜ ✗ 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读取:

I try to read it from 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]

由于每个人都拥有该文件的读取权限,所以如何来?

how come, as everyone has a read permission to that file?

推荐答案

操作系统的文件权限与此无关。看到堆栈跟踪,或者实际上是异常的Javadoc。此异常来自Java安全管理器,而不是操作系统。您正在安全管理器下运行(为什么?),您尚未授予您在.policy文件中访问该文件的权限。

The operating system's file permissions have nothing to do with it. See the stack trace, or indeed the Javadoc of the exception. This exception comes from the Java security manager, not the operating system. You are running under a security manager (why?) and you haven't granted yourself permission to access that file in your .policy file.

这篇关于AccessControlException:访问被拒绝为可读文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆