1

I have a project in Eclipse which reads and writes new files- it works with Eclipse, but when I save it to a jar it no longer works. For example:

readConfig(newFile(Settings.class.getProtectionDomain().getCodeSource().getLocation().getPath() + "chronos/Functions/config"));

Therefore, how do I load files from a outside source (assuming there is no way to do it inside a jar)?. For example, if I had my JAR in a folder with another called data- what would I type in to access the data folder?

c0der
  • 18,467
  • 6
  • 33
  • 65
Bruce
  • 37
  • 6

1 Answers1

0
  • If you just need to read you should be able to use getResourceAsStream() to read a file inside of the jar.
  • If you want to read and write use a folder next to the jar file. See here for an answer.
Community
  • 1
  • 1
Chris K
  • 1,703
  • 1
  • 14
  • 26