Files
aston-java-homework/hw-02/student-reader/src/main/java/com/example/StudentReader.java
T

21 lines
599 B
Java
Raw Normal View History

package com.example;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
public final class StudentReader {
public static List<Student> read(Path path) throws IOException {
return MAPPER.readValue(path.toFile(), new TypeReference<List<Student>>() {});
}
private StudentReader() {}
private static final ObjectMapper MAPPER =
new ObjectMapper().registerModule(new JavaTimeModule());
}