I've been making a game and when it came to making the code much less messy i came across a null-pointer so i gave up and held Ctrl+z (undo) for a bit until it stopped. The code was back to normal but when i ran it, it comes up with the same null-pointer to do with a class that i didn't change what so ever. The null-pointer is as follows:
Starting programm...
Exception in thread "main" java.lang.NullPointerException
at java.io.Reader.<init>(Unknown Source)
at java.io.InputStreamReader.<init>(Unknown Source)
at game.shaders.ShaderProgram.loadShader(ShaderProgram.java:98)
at game.shaders.ShaderProgram.<init>(ShaderProgram.java:25)
at game.shaders.StaticShader.<init>(StaticShader.java:34)
at game.renderEngine.MasterRenderer.<init>(MasterRenderer.java:32)
at game.engineTester.MainLoop.main(MainLoop.java:57)
The ShaderProgram seems to be causing the problem at line 98 were a bufferedreader is created and defined. The ShaderProgram lines that causes the error is as follows:
try{
InputStream in = Class.class.getResourceAsStream(file);
BufferedReader reader = new BufferedReader(new InputStreamReader(in)); // line 98, has nullpointer ???
String line;
while((line = reader.readLine())!=null){
shaderSource.append(line).append("\n");
}
reader.close();
}catch(IOException e){
e.printStackTrace();
System.exit(-1);
}
i am using lwjgl for this the source for this DOES exist even though some people are complaining that it isnt. it is within the shaders package and it is vertexShader.txt and fragmentShader.txt