Is there a way for a JAR file to read a text file (or any file for that matter) from within itself, no matter what platform? If so, how?
Printable View
Is there a way for a JAR file to read a text file (or any file for that matter) from within itself, no matter what platform? If so, how?
Use the methot getResourceAsStream(), for example, the following code will read MyFile.txt from within the Jar file:
Code :MyClass.getResourceAsStream("com/mycompany/MyFile.txt");
java exception
+thanks this helps me alot