Getting current directory from an applet
Hi. How can I get the current directory of my applet running on web without having to worry about permissin. I used the one below:
curDir = System.getProperty("user.dir");
but I get this error:
ava.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
any substiture for this? Thanks.
[430 byte] By [
Kaela] at [2007-11-27 3:51:12]

was trying to read from a text file but it's giving me some diffrent error messages so i decide d to show the path to make sure that it can see the file.
is it possible for an applet to read directory structure of my server cuz I'm getting a permissin problem still even though the atributes are all set to 777 from parent folder down to the last one.
Thanks.
Message was edited by:
Kael
Kaela at 2007-7-12 8:55:10 >

You want your applet to read the directory structure on the server? Do you realize it's running on the client, not the server, and that applets have severe restrictions on what they may do?What are you trying to do, what is your goal?
You should be using URLs or similar approaches, and avoiding File, which will
never work with an ordinary applet.
InputStream in = this.getClass().getResourceAsStream("file.txt");
That assumes the txt file is in the same place as the current classes .class file.
For example, the same folder or that they are jarred in the same "folder" in the jar.
You can also use a URL directly:
URL url = ...
InputStream in = url.openStream();
and you can construct that URL with the help of Applet methods getDocumentBase or getCodeBase:
URL url = new URL(this.getDocumentBase(), "file.txt");
That assumes the txt file is in the same folder as the html file in which the applet is embedded.