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

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

Joined: Oct 27, 2005
Posts: 20078

"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

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:
subject: Regarding InputStream doubts..
It's not a secret anymore!