java.io.FilePermission - access denied
Exception in thread "AWT-EventQueue-1" java.security.AccessControlException: acc ess denied (java.io.FilePermission write)
i开发者_开发技巧 am getting the above error when i tried to write into a file.
what i need to do kindly help out...
i am running an applet application...
Applets are by default denied from accessing the client's file I/O. You need to sign your applet or edit the policy files.
As far as i know Applets cannot write to files as this would be a security violation. You can expressly grant the file-writing permission to the JVM to enable this but i think that would be a really bad idea because your users would be allowing you to write whatever you wanted to their disk via the web. Why does your applet want to write to a file?
Is your applet signed? Non signed applets can't access files. See here: http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html
Do like this:
fos=AccessController.doPrivileged(new PrivilegedAction()
public FileOutputStream run() {
return new FileOutputStream(f1);
}
});
or edit file "java.policy
" add
permission java.io.FilePermission "<<ALL FILES>>", "read,write"
;
精彩评论