[jboss-user] [Beginner's Corner] - Re: JBOSS 6: Exploded War - path not found
jaikiran pai
do-not-reply at jboss.com
Wed Sep 28 18:18:43 EDT 2011
jaikiran pai [http://community.jboss.org/people/jaikiran] created the discussion
"Re: JBOSS 6: Exploded War - path not found"
To view the discussion, visit: http://community.jboss.org/message/628957#628957
--------------------------------------------------------------
> oakleyx wrote:
>
>
> Currently this is the code that i'm calling to return the path:
>
> ClassLoader loader = Thread.+currentThread+().getContextClassLoader();
>
> URL url = loader.getResource(*this*.filename);
> ..
> ..
> String path = url.getPath();
> repos = *new* File(path);
>
> ..
>
You have done that partially right. You shouldn't be using the absolute file path while working in Java EE environment. Instead, what you (typically) need to do is:
InputStream is = classLoader.getResourceAsStream(filename);
// then use the inputstream for further processing.
How do you use the "repos" later on in your code?
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/628957#628957]
Start a new discussion in Beginner's Corner at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110928/e9307779/attachment.html
More information about the jboss-user
mailing list