java.lang.NullPointerException when trying to read txt file in java -


i'm not sure why i'm getting npe, can read other files in directory next src/main/resources.

its maven based project run eclipse.

any ideas?

java ..

stringbuilder sb = new stringbuilder(); try {      inputstream = shadercontrol.class.getresourceasstream("fragmentshader.txt");     bufferedreader br = new bufferedreader(new inputstreamreader(is, "utf-8"));      string line;     while ((line = br.readline()) != null) {          sb.append(line);         sb.append('\n');     }     is.close();  } catch (exception e) {     e.printstacktrace(); } system.out.println("shader " + sb.tostring()); 

console output ..

java.lang.nullpointerexception     @ java.io.reader.<init>(reader.java:90)     @ java.io.inputstreamreader.<init>(inputstreamreader.java:119)     @ justc0de.engine.tools.shadercontrol.loadshader(shadercontrol.java:36)     @ justc0de.engine.ui.gamerenderer.init(gamerenderer.java:157)     @ jogamp.opengl.gldrawablehelper.init(gldrawablehelper.java:640)     @ jogamp.opengl.gldrawablehelper.init(gldrawablehelper.java:662)     @ javax.media.opengl.awt.glcanvas$9.run(glcanvas.java:1366)     @ jogamp.opengl.gldrawablehelper.invokeglimpl(gldrawablehelper.java:1275)     @ jogamp.opengl.gldrawablehelper.invokegl(gldrawablehelper.java:1131)     @ javax.media.opengl.awt.glcanvas$11.run(glcanvas.java:1394)     @ java.awt.event.invocationevent.dispatch(invocationevent.java:314)     @ java.awt.eventqueue.dispatcheventimpl(eventqueue.java:750)     @ java.awt.eventqueue.access$300(eventqueue.java:115)     @ java.awt.eventqueue$3.run(eventqueue.java:711)     @ java.awt.eventqueue$3.run(eventqueue.java:709)     @ java.security.accesscontroller.doprivileged(accesscontroller.java:311)     @ java.security.protectiondomain$1.dointersectionprivilege(protectiondomain.java:88)     @ java.awt.eventqueue.dispatchevent(eventqueue.java:720)     @ java.awt.eventdispatchthread.pumponeeventforfilters(eventdispatchthread.java:254)     @ java.awt.eventdispatchthread.pumpeventsforfilter(eventdispatchthread.java:173)     @ java.awt.eventdispatchthread.pumpeventsforhierarchy(eventdispatchthread.java:162)     @ java.awt.eventdispatchthread.pumpevents(eventdispatchthread.java:158)     @ java.awt.eventdispatchthread.pumpevents(eventdispatchthread.java:150)     @ java.awt.eventdispatchthread.run(eventdispatchthread.java:103) shader  program link error:  

directory listing ..

rob@work:~/git/justc0de$ ls src/main/resources/*.txt src/main/resources/fragmentshader.txt  src/main/resources/vertexshader.txt 

discovered should have been ..

inputstream = shadercontrol.class.getresourceasstream("/fragmentshader.txt"); 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -