I'm creating a little project that needs ".txt" files; they exists, and everything works fine on Eclipse, but when I export as a Runnable Jar File, the program don't find the needed files (they are inside the .jar file, I checked with WinRar). What can I do?
Asked
Active
Viewed 23 times
0
-
Objects in jars are not files and cannot be accessed using the file APIs. Show us how you are trying to access the objects in the jar. – greg-449 Feb 11 '16 at 16:10
-
WIth a BufferedReader. Most precisely: try(BufferedReader br = new BufferedReader(new FileReader("src/main/lista.txt"))) – Silvio Sandri Jr Feb 11 '16 at 18:23
-
As I said you can't use File based APIs for objects in a jar. Look at `Class.getResourceAsStream` – greg-449 Feb 11 '16 at 18:42
-
It returns a InputStream, how I can use it in my case? – Silvio Sandri Jr Feb 12 '16 at 00:11