Monday, 19 August 2013

Issue when trying to use getResourceAsStream in java

Issue when trying to use getResourceAsStream in java

So basically I have two lines in my code that are as follows:
InputStream is =
this.getClass().getClassLoader().getResourceAsStream("resources/config");
BufferedReader bufferedReader = new BufferedReader(new
InputStreamReader(is));
and my file structure in eclipse is as follows (image posted):

When I try to run this code, I get NullPointerExceptions when it reaches
the second line (BufferedReader line). I can't for the life of me figure
out why InputStream "is" is becoming null. Any ideas?

No comments:

Post a Comment