This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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: 20078
    
  30

"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 - OCEJPAD 6
How To Ask Questions How To Answer Questions
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Regarding InputStream doubts..
 
It's not a secret anymore!