0

I have a project that I use/export as a jar in an other project. In the jar project, I want to list some files .txt contained in one of my project directories.

How can I do that ? I made some researches but I only found solutions to list files in a jar, but not from the jar in question.

I tried to make a file using MyClass.class.getProtectionDomain().getCodeSource().getLocation().getPath() + "\MyRepertoryWithTxtFiles" and then using File.listFiles() but it makes a null pointer exception.

Hope my problem is understandable and thanks in advance for any suggestion.

Gulle
  • 23
  • 5
  • Welcome to stackoverlow. Generally we expect you to demonstrate in the question anything you've already tried. Please read help for more details. – marko Mar 09 '14 at 11:29
  • If the file is included in the jarfile, I think you're looking for http://stackoverflow.com/questions/2593154/get-a-resource-using-getresource – keshlam Mar 09 '14 at 14:57
  • I already tried the getResource() method, but it works only for a particular file, like "Resources/file.txt". Not for a directory that contains several files. – Gulle Mar 09 '14 at 15:23

0 Answers0