Meaningless Drivel is fun!*
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: 19653

"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 agree. Here's the link:
subject: Regarding InputStream doubts..
Similar Threads
How to create a ResourceBundle from a file name (not a base name)
difference between BufferedInputStream(or output) and other i/ostreams,regarding buffers.
Keeping Images for a Employee Object
What are the IO superclasses that write to network sockets?
Sending a xml file as a method parameter to a session bean