Saturday, April 28, 2012

How to read files in relative folder deployed in EAR


When you need to read files in relative folder deployed in EAR use this:

URL myURL = this.getClass().getClassLoader().getResource("relative_path/file.extension");
if (myURL != null){
   return myURL.getPath();
     }else{
       return "null path";
}

No comments:

Post a Comment