Is it possible to read/write a file from an applet

孤街醉人 提交于 2019-12-23 12:34:26

问题


I've trying to read and write a file from an applet so if I run the applet from my appletviewer it is possible for me to read/write a file but when I try to do it from my browser I get a security exception. Any idea how to do this?


回答1:


Is it possible to read/write a file from an applet

Yes, but you need to sign the applet and get approval from the user.

Some useful links:

  • How can an Applet read files on the local file system (from coderanch.com)
  • Essentials, Part 1, Lesson 6: File Access and Permissions (from oracle)
  • Chapter 10: Signed Applets (from oracle)



回答2:


A sand-boxed JWS app. can read and write to files on the local file system using the JNLP API services. Here is a demo. of the JNLP API file services. The downloadable Zip file contains the source, launch file and build script.




回答3:


it's actually not that difficult. You can self sign an applet and then it will be able to read/write to/from the local file system outside the sandbox constraints. take look at the link below. it will show you how to sign your applet using the keytool and the example actually does read/write to the filesystem. no need to muck about the policy files and such.

Note that as @aioobe mentioned, the user will be prompted to accept the certificate though.



来源:https://stackoverflow.com/questions/7406871/is-it-possible-to-read-write-a-file-from-an-applet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!