JBoss Community

Re: JBOSS 6: Exploded War - path not found

created by jaikiran pai in Beginner's Corner - View the full discussion

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

Start a new discussion in Beginner's Corner at Community