Read text file with Reader from a jar file

Hi! I wanna know how to read a text file that is inside my main jar file.

here's my code

String iniFileName ="/ini/ImportD.ini";

String line =null;

File iniFile =null;

Vector vecTemp =new Vector();

java.net.URL url = getClass().getResource(iniFileName);

if(url ==null) blablablado something

iniFile =new File(url.getFile());

BufferedReader reader =new BufferedReader(new FileReader(iniFile));

while((line = reader.readLine()) !=null){

vecTemp.add(line);

}

I know I could use getClass().getRessourceAsStream(iniFileName), but I DO want to use a BufferedReader because I need to read my text file line by line ( readLine() ).

The command "BufferedReader reader = new BufferedReader(new FileReader(iniFile));" throw an NullPointerException.

If I run the apps with Eclipse (not with my jar file) it works perfectly.

Any suggestions?

Thanks.

[1406 byte] By [k@tzea] at [2007-10-2 15:25:51]
# 1
Construct the kind of reader you want, passing it the input stream.
bschauwejavaa at 2007-7-13 14:41:28 > top of Java-index,Java Essentials,Java Programming...
# 2

>I know I could use getClass().getRessourceAsStream(iniFileName), but I DO want to use a BufferedReader

> because I need to read my text file line by line ( readLine() ).

So what is stopping you?

InputStream input = getClass().getResourceAsStream(iniFileName);

BufferedReader reader = new BufferedReader(new InputStreamReader(input));

Regards

jfbrierea at 2007-7-13 14:41:28 > top of Java-index,Java Essentials,Java Programming...
# 3
InputStreamReader!!! That's it!! That's the class between Readers and Streamers. I didn't know that class, thanks a lot.
k@tzea at 2007-7-13 14:41:28 > top of Java-index,Java Essentials,Java Programming...