Hi.
I'm trying to read some questions and answers from a text file. After each click, the next set of text should be displayed and it works until it reaches the last set (the last five lines in the file, which are all "0". Actually the simulation should stop there, but it doesn't). Then it throws an IOException and I don't know how to fix this...
I would be grateful for some help.
Thanks
String line = null; int c=0; try { if((line = reader.readLine()) != null) { if(line=="0") Greenfoot.stop(); Q.settext(line); A1.settext(reader.readLine()); A2.settext(reader.readLine()); A3.settext(reader.readLine()); c=Integer.parseInt(reader.readLine()); } } catch (FileNotFoundException e) {throw new RuntimeException("File not found");} catch (IOException e) {throw new RuntimeException("IOException");} finally { if(file != null) { try { file.close(); } catch (IOException e) {e.printStackTrace();} } }