import java.io.;
import java.nio.file.;
import java.util.;
import java.util.stream.;
class Student {
private String id;
private String name;
private int age;
private String address;
public Student(String id, String name, int age, String address) {
this.id = id;
this.name = name;
this.age = age;
this.address = address;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
public String getAddress() {
return address;
}
}
interface StudentService {
void addStudent(Student student) throws IOException;
List listStudents() throws IOException;
Optional findStudentById(String id) throws IOException;
void deleteStudentById(String id) throws IOException;
}
class FileStudentService implements StudentService {
private static final String FILE_PATH = “students.txt”;
@Override
public void addStudent(Student student) throws IOException {
try (BufferedWriter writer = Files.newBufferedWriter(Paths.get(FILE_PATH), StandardOpenOption.CREATE, StandardOpenOption.APPEND)) {
writer.write(student.getId() + “,” + student.getName() + “,” + student.getAge() + “,” + student.getAddress());
writer.newLine();
}
}
@Override
public List listStudents() throws IOException {
return Files.lines(Paths.get(FILE_PATH))