W
Wendy S
I need to pick up a file sitting in WEB-INF/classes, which I usually do like
this:
ClassLoader cl = MyClassName.class.getClassLoader();
InputStream rules = cl.getResourceAsStream( XML_RULES );
But an InputStream won't do, the createDigester method takes either
org.xml.sax.InputSource or java.net.URL .
Initially, I had this:
ClassLoader cl = MyClassName.class.getClassLoader();
InputStream rules = cl.getResourceAsStream( XML_RULES );
Digester digester = DigesterLoader.createDigester( new InputSource(
rules) );
And then I got it down to:
ClassLoader cl = MyClassName.class.getClassLoader();
Digester digester = DigesterLoader.createDigester( cl.getResource(
XML_RULES ) );
(ClassLoader.getResource returns a URL.)
There's probably a more direct path, I just don't see it.
What methods other than ClassLoader.getResource and getResourceAsStream can
find things on the classpath? InputSource has a constructor that takes a
'system identifier' but I haven't been able to figure out exactly what that
is.
Thanks once again!
this:
ClassLoader cl = MyClassName.class.getClassLoader();
InputStream rules = cl.getResourceAsStream( XML_RULES );
But an InputStream won't do, the createDigester method takes either
org.xml.sax.InputSource or java.net.URL .
Initially, I had this:
ClassLoader cl = MyClassName.class.getClassLoader();
InputStream rules = cl.getResourceAsStream( XML_RULES );
Digester digester = DigesterLoader.createDigester( new InputSource(
rules) );
And then I got it down to:
ClassLoader cl = MyClassName.class.getClassLoader();
Digester digester = DigesterLoader.createDigester( cl.getResource(
XML_RULES ) );
(ClassLoader.getResource returns a URL.)
There's probably a more direct path, I just don't see it.
What methods other than ClassLoader.getResource and getResourceAsStream can
find things on the classpath? InputSource has a constructor that takes a
'system identifier' but I haven't been able to figure out exactly what that
is.
Thanks once again!