I have been trying to create a basic app for a quiz as part of my research, but I am running into trouble with the buffered reader. I have searched everywhere for info on the errors and the actual bufferedreader method, but can't find a thing. Here is my method so far, and the errors are:
unreported exception java.io.IOException; must be caught or declared to be thrown
and the other one is
missing return statement.
public String showMathsNotes() throws IOException{
BufferedReader br = new BufferedReader(new FileReader("ReligionNotes.txt"));
String note = br.readLine();
}
The first error comes from another method which is calling this one. Here is an extract from it:
switch(choice2){
case 1: System.out.println(showMathsNotes());break;
case 2: System.out.println(showEnglishNotes());break;
case 3: System.out.println(showReligionNotes());break;
default: System.out.println("Invalid Entry");break;
*************************EDITED***************************
I am now receiving the error
unreported exception java.io.IOException; must be caught or declared to be thrown
I have arranged the code to this now:
public void showMathsNotes()throws IOException{
try{
BufferedReader br = new BufferedReader(new FileReader("MathsNotes.txt"));
String note = br.readLine();
}catch(IOException e){
e.printStackTrace();
}
}