Syed M. Shaaf

programmer, linux geek...

How to read a file from the JAR?

31 Oct 2008 »

Someone just asked me this question today. And I thought might as well put it down for info.

’’’ public TestReadFileFromJar() throws FileNotFoundException, IOException { InputStream is = getClass().getResource(“txtData/”); read(is); } ‘’’

In the case above txtData is placed in the jar on the root. Remmember to add the path with the “/”