This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes difference among different getResourceAsStream()? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "difference among different getResourceAsStream()?" Watch "difference among different getResourceAsStream()?" New topic

difference among different getResourceAsStream()?

Yan Zhou
Ranch Hand

Joined: Sep 02, 2003
Posts: 136

What is the difference among these three getResourceAsStream():


Pedro Gongora

Joined: Oct 03, 2003
Posts: 17
I think that the difference is on the classloader and methods that are used to find the resource.
Classloaders have a hierarchy, that is, they form some kind of tree (where context classloader is the root of the tree) and resources (classes or properties files) loaded into memory by some classloader might no be visible to their parent.
Also, they differ on where they search for the resource, for example, HttpServletRequest has a getResourceAsStream() method, that searches for resources under /WEB-INF either if webapp is "exploded" on the filesystem or packaged in a .war archive. Other getResourceAsStream() methods don't do that.
You have to read documentation for specific behaviour of each method.
Please, does anybody could confirm this ?
subject: difference among different getResourceAsStream()?
Similar Threads
ResourceBundle design problem
Can't use properties file in EJB project developed in WSAD
IDE: eclipse; Problem: embedded Images
need help reading a properties file