Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Directory / File not found

 
Paulo Carvalho
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I deployed a WAR file into Tomcat. This WAR file has a JAR file inside. Inside this JAR file, there is a directory structure: a directory called "mods" with a "fr" subdirectory.

So, the JAR file have something like this:

...
META-INF
mods
fr
...


The JAR file has a java class which tries to access the mods/fr directory:



Unfortunally, the directory is not found.

I have put the following lines to verify this:



=> it prints "C:\Programs\apache-tomcat-6.0.24\bin\mods\fr"



=> it prints "false" and "false".


What am I missing? how can I do for mods/fr directory to be found my the class of the JAR which is into the WAR file?

Thanks
Best regards

 
Ogeh Ikem
Ranch Hand
Posts: 180
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Paulo. Are you trying to access a resource in that directory? In that case,

use this

or this

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64184
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A jar file is not a file system. You cannot use file I/O. As pointed out, you must obtain it as a resource.
 
Paulo Carvalho
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

Thanks for the answers.

In fact, what I want to do is to access the "mods/fr" directory which is in the JAR file and list all the files that ends with the "txt" extension.

So, resuming, I don't have the name of the ressource files, I just have the name of the directory where they are...

How can I list all the "txt" files present in the directory?

Thank you

Regards
 
Ogeh Ikem
Ranch Hand
Posts: 180
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use this code to print the name of every file in a jar file.

You can implement a simple filter to print only the names of files in the "mods/fr" directory that end with the "txt" extension.

 
Paulo Carvalho
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the clue.
I will try it.

Best regards
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic