Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How can I use the buffered reader for input a text file? it\'s giving me File no

ID: 3709996 • Letter: H

Question

How can I use the buffered reader for input a text file?

it's giving me File not found exception error. the file is named CourseFor Program.txt and its located on my mac Desktop under Lab 11 folder

public static void readData(LinkedListccourse> aList) throws NumberFormatException, IOException( String line; BufferedReader br BufferedReader(new FileReader (System.getProperty("user.dir") + "\Lab 11\CourseForProgram . txt")); = new while ((line = br . readLine()) != null){ String[ ] colon-line . split(": "); Stringt1 classLevel-colon(0].split(" "); //class &level; Stringl1 descGrade-colon( 1).split(" ") //description & grade Course temp; if (descGrade.length >1) //if a grade is present aList.add(new Course(classLevel[0], Integer.parseInt (classLevel[1]), descGrade[0], descGrade[ 11)) elset aList.add (new Course(classLevel[0], Integer.parseInt (classLevel[1], descGrade[0], null))

Explanation / Answer

The synatx of reading file in unix using buffered reader is

string dir = system.getproperty ("user.home") + "/desktop/Lab 11";
file myfile = new file (dir + "CourseForProgram.txt");

BufferedReader br=new BufferedReader(new FileReader(myfile));

also use user.home insted of user.dir while specifying base directory

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote