简体   繁体   中英

Java Read File Permissions

I was wondering if anybody can show me way to be able to create read file permissions for my java applet.

The exact exception I receive is

java.security.AccessControlException: access denied(java.io.FilePermission filename.pdf write)

I've put f.setReadable and f.setWriteable where f is the file and nothing. A little help please.

There's security limits on what an unsigned applet can do, and one of the things it can't do is access the local filesystem (see here for a full list). You have several options:

  1. Sign your applet . If a user then runs your applet it won't run with any security restrictions. However, signing your applet with a trusted certificate costs at least $100 a year, and if you self-sign then nobody is going to trust your applet. And even if you do sign with a trusted certificate the user might decide not to run it.
  2. Set up your applet with a JNLP file . This will let your applet use the javax.jnlp package. You can then use the FileOpenService and FileSaveService to ask the user to let you read/write one particular file. Alternatively, you can use the PersistenceService to store a small amount of data persistently within the browser.

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