When reading resources from a JAR file, you cannot use the File
API. Instead, you use Class.getResourceAsStream()
, like this:
reader = new InputStreamReader(MyClass.class.getResourceAsStream(
"/apathdir/textFile.txt"), "UTF-8");
Note also how the encoding is specified. FileReader
does not allow that, which is why it should usually be avoided.