I have this code:
public class JsonFileHandler<T> {
public T getContent(File file) {
T t = null;
ObjectMapper mapper = new ObjectMapper();
if (!file.exists()) {
return null;
} else try {
t = mapper.readValue(file, T.class);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
return t;
}
}
but I get compilation error on this line:
t = mapper.readValue(file, T.class);
which has this signature:
public <T> T readValue(File src, Class<T> valueType)
how can I fix this?