Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading files in a directory of the jar file

 
Andr� Jesus
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I've created an applet and I'm running it from a browser accessing a jar file.

I can read the contents of a file using getClass().getResourceAsStream(nameofthefile) but I want to read the contents of all the files in a subdirectory of the jar so I don't have the file names.

Is there any way I could find all the file names in this subdirectory of the jar.

Thanks, and sorry for the poor english.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't you create a JarInputStream from the InputStream returned by getResourceAsStream, and then deal with the files by using the methods of JarInputStream?
 
Andr� Jesus
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, it worked fine once I've opened the jar file, but when I open the applet on the browser I get an Exception.

This is the code:
URL url = new URL("http://localhost:8080/.../myfile.jar");.
I get an AccessControlException

I am trying to read files in the same jarfile the applet is running in. Is there any problems in opening this file again (the applet is already runnig in the browser)?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you run the applet off the localhost web server, or directly from the file system, i.e. does the browser URL field say "http://localhost..." or "file:///..."?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic