Hi... I really have a big problem in this program... I dont know how to properly read a user input from a text file.
I will really appreciate your help. thanks.
import java.util.*;
import java.io.*;//--------------------------in this part is my problem----------------------//
public void openFile() {File myFile = new File("students.txt");
try {
BufferedReader in = new BufferedReader(new FileReader(myFile));
String n ,i,y,c, name, id, year, course;try {
n=in.readLine();
i=in.readLine();
y=in.readLine();
c=in.readLine();while(n!=null && i!=null && y!=null && c!=null) {
name=n;
id=i;
year=y;
course=c;n=in.readLine();
i=in.readLine();
y=in.readLine();
c=in.readLine();stud.add(new Student(name,id, year, course));
n=in.readLine();
i=in.readLine();
y=in.readLine();
c=in.readLine();}
} finally {
in.close();
}} catch (FileNotFoundException e1) {
System.out.println("File not found: " + myFile);} catch (IOException e2 ) {
e2.printStackTrace();
}
}