GeeCON Prague 2014*
The moose likes Java in General and the fly likes Regarding InputStream doubts.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Regarding InputStream doubts.." Watch "Regarding InputStream doubts.." New topic
Author

Regarding InputStream doubts..

Chandra Mohan
Ranch Hand

Joined: Oct 06, 2003
Posts: 62
The following line throws null pointer exception while executing in RAD. Not sure about the reason. The XML file has present in the exact path and have access to the system.

InputStream is = Thread.currentThread().getContextClassLoader(). getResourceAsStream("c://services.xml");

Suggestions are welcome.


Thanks and Regards
Chandra Mohan
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

"c://services.xml" is not a resource - it's a full path.

Resources are only for files located relative to your class / class loader. If you have the absolute path, use the following:
- new FileInputStream(...) if you need an InputStream
- new File(...).toURI().toURL() if you need a URL


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
GeeCON Prague 2014
 
subject: Regarding InputStream doubts..