I have an applet which have to read a file from server. But I receive the following exception
我有一个小程序,必须从服务器读取文件。但我收到以下例外情况
java.security.AccessControlException: access denied (java.io.FilePermission \kb1.xml read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkRead(Unknown Source)
at java.io.File.isDirectory(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
...
I tried to put a java.policy.applet file with permission granted for reading but it doesn't work. I need a quick way to solve this problem. I have to specify that for making this applet I used java 6.
我试图放一个java.policy.applet文件,该文件具有读取权限,但不起作用。我需要一个快速的方法来解决这个问题。我必须指定为了制作这个applet,我使用的是java 6。
1 个解决方案
#1
You said you want to read a file on the server, but the exception is caused by trying to read a file on the client (the machine that is running the applet).
您说您想要读取服务器上的文件,但是异常是由于尝试读取客户端(运行applet的机器)上的文件引起的。
You cannot read files from the server directly. You need to access them via HTTP or put them into the applet's jar file and load it from there.
您无法直接从服务器读取文件。您需要通过HTTP访问它们或将它们放入applet的jar文件并从那里加载它。
#1
You said you want to read a file on the server, but the exception is caused by trying to read a file on the client (the machine that is running the applet).
您说您想要读取服务器上的文件,但是异常是由于尝试读取客户端(运行applet的机器)上的文件引起的。
You cannot read files from the server directly. You need to access them via HTTP or put them into the applet's jar file and load it from there.
您无法直接从服务器读取文件。您需要通过HTTP访问它们或将它们放入applet的jar文件并从那里加载它。