assume that i have this code in a project A
:
public class test {
public void myMethod() {
String directoryPath = classLoader.getResource("") + "/templates/code/";
// code to read directory files
}
}
First Problem
and have some specific files in resources/templates
directory of this project. and want to get all of the files that in the resources/templates
directory.
I'm added that project as a dependency to another project named B
and want to call myMethod
.
now, the myMethod
works fine when calling in project A
, but when i'm call it in B
project it throws FileNotFoundException
.
I'm call the myMethod
in project B
as you seen below:
public class myClass {
public static void main(String[] args) {
myMethod();
}
}
NOTE
1- Both of that projects is Spring, Maven project
2- When i build project B
, the jar file of project A
is in WEB-INF/lib
directory of B
.