From your given example, it is not clear what fileName
refers to. You should just use the stream you got from getResourceAsStream()
to read you file, something along
reader = new BufferedReader(new InputStreamReader(istream));
And you should avoid to repeatedly allocating buf
new for every read cycle, once is enough.