[英]Java Code Applet Error: java.security.AccessControlException: access denied (“java.io.FilePermission” “MyFile.txt” “read”)
I got the following error while i was trying to read a file and store it's data into my applet(Java) i think that the main error is this :我在尝试读取文件并将其数据存储到我的小程序(Java)中时出现以下错误,我认为主要错误是:
java.security.AccessControlException: access denied (
"java.io.FilePermission" "MyFile.txt" "read")
And I have no idea how to resolve it, thought it might something to add to my java.policy.applet
file which include:我不知道如何解决它,认为它可能会添加到我的
java.policy.applet
文件中,其中包括:
grant {
permission java.security.AllPermission;
};
I also tried to google it but nothing works.我也试过用谷歌搜索,但没有任何效果。
Thanks for the comments guys,谢谢各位大佬的评论
i have solved this problem by reading "MyFile.txt" as a URL, and then read it我通过读取“MyFile.txt”作为 URL 解决了这个问题,然后读取它
the code:编码:
URL myURL = new URL("http://MyDomainName.com/MyFile.txt");
BufferedReader in = new BufferedReader(
new InputStreamReader(myURL.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
line.add(inputLine);
in.close();
Solved解决了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.