1. getClass().getClassLoader().getResourceAsStream is throwing a NullPointerException stackoverflow.comIn Java How could getClass().getClassLoader() return null?
|
2. Class.getResource(String) and Class.getResourceAsStream(String) coderanch.com-------------------------------------- Hi, I have a question about the getResource(String) and getResourceAsStream(String) methods in the Class class. What exacty are the "resources"? Why is the return of getResource(String) a URL? Thanks. -------------------------------------------- Hi, Resource is some data like images, text... that can accessed by the class code. It returns the URL for reading the resource. I haven't tried these methods, so I ... |
3. getResourceAsStream returning null coderanch.com |
4. getResourceAsStream i get null. coderanch.com |
5. .getResourceAsStream null coderanch.comAre you trying to load the resource from a jar? In that case, the String should probably be something like "/WEB-INF/classes/global.properties". If the resource is not in a jar, or in a location that is relative to the class file, you should probably use the Path class to get access to the resource. |
6. getResource returns null but getResourceAsStream work.. pls help. forums.oracle.comHi, I have a web application deployed on a web logic server. I need to read a custom xml file from the public_html\WEB-INF folder. input = ctx.getResourceAsStream("WEB-INF/myfile.xml"); // works fine try { URL u = ctx.getResource("WEB-INF/myfile.xml"); // return null. Any idea why the url is not working? 2) Is there any way I can read the file outside the servlet context? ... |
7. getResourceAsStream retrive null forums.oracle.comA quote from the API doc The path must begin with a "/" and is interpreted as relative to the current context root. You can't use that method to get a file, unless that file exists under the context root of the servlet, use a normal FileInputStream and replace "\" with either "/" or " ". Edit: Or better yet, place ... |