A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Node.js in Action
this week in the
EJB and other Java EE Technologies
Resource Loading from Container Apps
Joined: Mar 19, 2005
Mar 19, 2005 12:15:00
I am looking for knowledge pointers on how to load a resource as stream from within a 2.0 compliant application. My utility class needs file resources that are/will be included in the root of a jar. Any help with this process is greatly appreciated.
4.XX on WinXP,Linux...
Joined: Feb 17, 2005
Mar 19, 2005 16:43:00
Here there is a piece of code that loads an xml stream at runtime:
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(xmlFile.getName()); SAXBuilder builder = new SAXBuilder(); Document dom = builder.build(in); Element root = dom.getRootElement();
There is one more side of the story: you need to understand your container class loader architecture in order to play with this code safely.
I think, therefore I exist -- Rene Descartes
It is sorta covered in the
JavaRanch Style Guide
subject: Resource Loading from Container Apps
accessing message resources in processPreprocess
Remote Administration of Websphere
Accessing Resource bundle from Facelets UI
How to use one resource bundle in another bundle?
Help: upgraded from tomcat 5.0 to 5.5.27 and getting Naming Exception
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014