I want to know, how to write a file to a resources folder in a Spring MVC project.
I defined the resources path in a web-dispatcher-servlet.xml
as
<mvc:resources mapping="/resources/**" location="/resources/" />
I read examples about how to read a file from a resources folder. But I want to write a file to a resources folder. I tried
ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource("file/test.xml").getFile());
if (file.createNewFile()) {
System.out.println("File is created!");
} else {
System.out.println("File already exists.");
}
But I get a
Request processing failed; nested exception is java.lang.NullPointerException