I have a JSON file in /src/main/resources
which I'm trying to read in the following way:
private List<String> readContextFromFile(String file) {
List<String> context = new ArrayList<>();
try {
InputStream in = getClass().getClassLoader().getResourceAsStream(file);
Map<String, ArrayList> input = objectMapper.readValue(in, HashMap.class);
context = input.get("@context");
} catch (IOException e) {
LOGGER.error("Error reading value {}", e.getMessage());
}
return context;
}
However, InputStream is null.
This is the file path that I pass: /resources/context.json
What am I doing wrong?