Two Laptop Bag*
The moose likes Applets and the fly likes How List the files in directory through Applet code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "How List the files in directory through Applet code" Watch "How List the files in directory through Applet code" New topic
Author

How List the files in directory through Applet code

Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 202
Hi,

I have a "Test.html" file and other supporting directories in "MyFolder"

In Test.html file I have the following tags with other text..

<applet id="listF" code="AppletClass.class" width="1" height="1">
<param name="archive" value="listfiles.jar">
</applet>

In listfiles.jar, i have a class file called as "AppletClass.class"

In this file (AppletClass.java) I am writing following code

/*where folder1 is one of the dependent folder residing with "Test.html"*/

File f=new file("folder1");
File f1[]=f.listFiles();

After adding these lines i repackaged to jar file and accessed Test.html

Now i am getting the following error..

java.security.AccessControlException:access denied (java.io.FilePermission folder1 read)

I check, the folder doesn't have any permissions.

Please let me know how to list the files and get solution for this problem...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
By default, applets can't access the local file system as a security measure. To get around that, they need to be signed, or the local security policy altered. See HowCanAnAppletReadFilesOnTheLocalFileSystem for details.


Ping & DNS - updated with new look and Ping home screen widget
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How List the files in directory through Applet code
 
Similar Threads
Using ANT to get a ZIP of changed folders
Can JSP handle this project?
how to show html page
Unable to call applet methods from javascript
Show dir and file structure exactly as it is