Java Jar file: How to read a file from a Jar file
Briefly

The trick to reading text files from JAR files are these lines of code, especially the first line: InputStream is = getClass().getResourceAsStream("3Columns.csv"); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr) ... I have a plain text file named " 3Columns.csv" in the same directory as the class that contains this method. Without a path stated before the filename (like "/foo/bar/3Columns.csv") the getResourceAsStream method looks for this text file in its current directory.
Note that I'm doing all of this within the context of a JUnit test method. Also note that I'm throwing any exceptions that occur rather than handling them. I don't recommend this for real-world programming, but it works okay for my unit testing needs today.
Read at Alvinalexander
[
add
]
[
|
|
]