FILE I/O TXT file
Hi.. i have a small problem... i have this file marks with the following contents:
1234567//Student ID
ENG3U//Course
86//Marks
2345671
MAT3C
45
1122334
ICS3M
78
5656453
ICE3M
67
Total of 3 students. What my program is supposed to do is that check the mark of the student for pass/fail. If he/she passes, only output the course and the mark to a pass.txt file and vice versa with fail.txt.
Right now, my program is not running. I am able to load the marks.txt file but when i try to write contents into another file for beginners, it doesnt output anything but makes a file... here's the code:
import java.io.*;
publicclass program6{
publicstaticvoid main (String args[])throws IOException{
System.out.println ("MARKING");
FileReader fr =new FileReader ("marks.txt");
BufferedReader br =new BufferedReader (fr);
//reading the contents of the file.
String a = br.readLine();
while (a !=null){
//call the pass fail method with contents.
passFail(a);
a = br.readLine();
}
a = br.readLine();
}
publicstaticvoid passFail(String line)throws IOException{
//PROBLEM HERE. IT IS NOT WRITING THE CONTENTS OF marks.txt to the testing.txt file.
File f =new File ("testing.txt");
BufferedWriter wr =new BufferedWriter (new FileWriter(f));
wr.write(line);
wr.close();
}
}
Can anyone help me

