hello,
i want to read a txt file from jar file
im using the following code
the file "level01.txt" is in the jar file - checked via zip
and was placed in a subfolder called "res"
the jarfile was created using jbuilder 5
my problem: my code cant find the file?
error >> java.lang.NullPointerException
ive tried different path/filename versions
such as:
"level01.txt"
"/level01.txt"
"/res/level01.txt"
does anybody have any idea?
thanks for any help
andreas
my code
=======
try {
InputStream is = this.getClass().getResourceAsStream("/level01.txt"
StringBuffer sb = new StringBuffer();
int chr;
while ((chr = is.read()) != -1)
{
sb.append((char) chr);
is.close();
}
System.out.println(" > reading OK!"
}
catch (Exception e)
{
System.out.println(" > ERROR: Cant Read File ERR= " + e);
}

;


