vlad_roubtsov
(member)
08/26/03 01:14 PM
Re: Neat.. .also can extend to loading from a class

If you are already using a well-defined resource naming scheme (inside URLs or otherwise), using Class.getResourceAsStream() offers almost no advantages, IMHO. This method is implemented as a very thin layer of abstraction over ClassLoader.getResourceAsStream(), with the classloader being the classloader that loaded the class in question.

Class.getResourceAsStream() provides a bit of value by supporting package-relative names, but since you already have to name the class in your example I don't think this is a real advantage. Such a class: scheme might be useful in its own right, though: as a scheme for "load this resource using whichever classloader will load this class" type of thing.



Contact us JavaWorld

Powered by UBB.threads™ 6.5.5

Featured White Papers


RESEARCH CENTERS: Java Standard Edition | Java Enterprise Edition | Java Micro Edition | Development Tools
About Us | Advertise | Contact Us | Terms of Service/Privacy
Copyright, 2006-2008 Network World, Inc. All rights reserved.