The text is printing in an infinite loop. Any way to avoid these?
if (eLoad) {
File file = new File("reservation.txt");
/** reading a file */
try(FileInputStream fis = new FileInputStream(file)) {
int content;
while ((content = fis.read()) != -1) {
// convert to char and display it
System.out.print((char) content);
/**print out the result contents of the file. */
}
}
catch(IOException e) {
e.printStackTrace();
}
}
Ooutput shown
Homeworkdue Sat Oct 10 00:00:00 PDT 2015 23:00 23
Homeworkdue Sat Oct 10 00:00:00 PDT 2015 23:00 23
Homeworkdue Sat Oct 10 00:00:00 PDT 2015 23:00 23