简体   繁体   中英

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.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:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM