I am using JAVA 8, Servlet 3.1 and springMVC without the web.xml
. I have placed a info.json
file in src\main\resources\data
. There is a util class from which i am trying to read the file. No matter what path i give am unable to read it. i get below exception :
java.nio.file.NoSuchFileException: WEB-INF\classes\data\info.json at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79) at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
I am trying to read the file as below :
public static <T> T unMarshal(String json, Class<T> clazz) throws IOException, URISyntaxException {
byte[] jsonData = Files.readAllBytes(Paths.get("WEB-INF\\classes\\data\\info.json"));
return objectMapper.readValue(jsonData, clazz);
}
also tried paths like
C:\\domain\\src\\main\\resources\\data\\info.json
src\\main\\resources\\data\\info.json
data\\info.json
I have tried different paths also tried fully qualified path still unable to read it. Also tried File path to resource in our war/WEB-INF folder? but unable to get hold of the context instance. Kindly suggest.