public static void main(String[] args)throws Exception {
File myFile=new File("try.txt");
if(myFile.exists()){
BufferedReader reader=new BufferedReader(new FileReader(myFile));//prepare stream
//get limit
int limit=Integer.parseInt(reader.readLine());
//read limit
Student list[]=new Student[limit];
//read content
for(int i=0; i<limit; i++){
list[i].name.First=reader.readLine();
list[i].name.Midle=reader.readLine();
list[i].name.Last=reader.readLine();
list[i].chairLocation.Column=Integer.parseInt(reader.readLine());
list[i].chairLocation.Row=Integer.parseInt(reader.readLine());
list[i].course=reader.readLine();
list[i].age=Integer.parseInt(reader.readLine());
}
//print contents
for(int i=0; i<limit; i++){
JOptionPane.showMessageDialog(null,"Seated at"+" "+"Column:"+list[i].chairLocation.Column+" "+"Row:"+list[i].chairLocation.Row+"\n"+"is"+
"\n"+"Name:"+list[i].name.First + " "+list[i].name.Midle+ " "+list[i].name.Last+"\n"+"Age:"+list[i].age+"\n"+"Course:"+list[i].course);
}
}
}
}
im trying to make an I/O that reads and searches the file the prints out the objects within the file. but i cant compile it cause of a numberFormat Exception.
i dont know what im wrong here. and im just studying file manipulation.
can somebody help out?
heres the text file:
Jaygee Marie Maiso Namata 23 ACT 1 1


Sign In
Create Account


Back to top









