Monday, 7 November 2011

Spring: how to locate a file in WEB-INF/classes/resources

The project if built with Spring and has the standard filesystem of Maven.

Assume we want to read foo.txt in WEB-INF/classes/resources/foo.txt

ClassPathResource r = new ClassPathResource("foo.xml");
try {
System.out.println("full path"+r.getFile().getAbsolutePath());
} catch (IOException e1) {

The output is the full path to foo.xml.


No comments:

Post a Comment