21 lines
599 B
Java
21 lines
599 B
Java
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());
|
|
}
|