private File getFile( String resourceName )
{
ClassLoader cloader = Thread.currentThread().getContextClassLoader();
URL resource = cloader.getResource( resourceName );
if ( resource == null )
{
throw new IllegalArgumentException( "Could not get resource: " +
resourceName );
}
return new File( resource.getPath() );
}
<PetPeeve>
Please be careful pulling resources like this. Those of us who've coded
with OSGi know that the URLs from ClassLoader.getResource() are not
necessarily resolvable to a path that will successfully yield a File. (I
owe the WebLogic team a long and painful chat about this one day.)
Unless you have a priori knowledge that in every possible environment
you'll actually have a File, the best thing is to open a stream from
that URL directly.
</PetPeeve>
I don't see why you should need to use the context classloader if the
resources are within the same domain (realm? scope? I'm looking for a
word which is a more formalized form of 'in the same JAR') as the class
you were referencing with
this.getClass().getClassLoader().getResource(). I'm assuming the
resources in question are definitely being included in the produced JARs?
- John
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]