I am running into an error
java.io.FileNotFoundException: C:\courses2.txt (The system cannot find the file specified)
checked the c drive and the path is correct but for some reason I am not getting the output.
The most I got was a return Teachers copy and Unable to Read the file.
My Output should show course code, course credit hours, and course title
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
public class courses
{
public static void main(String[] args) throws Exception
{
try {
File file = new File("C:\\courses2.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String courseCode = "";
String creditHours = "";
String courseTitle = "";
String st;
System.out.println("Teacher's Copy");
while ((st = br.readLine()) != null) {
courseCode = st.substring(0, st.indexOf(" "));
creditHours = st.substring(6, 8);
courseTitle = st.substring(9);
System.out.print("Course code = " + courseCode + " | ");
System.out.print("Course credit hours = " + creditHours + " | ");
System.out.print("Course Title = " + courseTitle);
System.out.println();
}
} catch (Exception ex) {
System.out.println(ex);
}
}
}