+1  A: 

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.

Michael Borgwardt
Hei man, thank you. its solved my problem.
Richard
I'd like to know how do i write in this file, this same way?
Richard
@Richard: you generally cannot write to the JAR file your program is loaded from since it's locked by the OS.
Michael Borgwardt
A: 

Iwant to know, if fileName = "textFile.txt", what is the path dir of this file?

If you only use a bare file name (without giving a directory), the JVM will look for the file in the current directory of the JVM process; that is usually the directory you ran the JVM (the java executable) from.

how do i do to set /apathdir/textFile.txt?. apathdir is a directory that is inside jar file. I tried: fileName = "/apathdir/textFile.txt", but doesn't works.

If you want to load a file from inside a JAR file, you cannot load it using FileReader. You need to use ClassLoader.getSystemResourceAsStream() (or Class.getResourceAsStream). See e.g. this article for an explanation:

http://www.devx.com/tips/Tip/5697

sleske