Hello, I do not understand the difference between an expected end of file and unexpected end of file. Reading under the section of Exception handling. It said that the method differentiates between expected and unexpected enf of file,,,
Page 570, Quote : Note that the method differenciate between the expected end of ile and an unexpected end of ile, all files must come to an end. The method is prepared for the case that the end of file has been reached before the start of record. In that case, the method simply returns false. However if the file ends in the middle of a record, then the method throws an excpetion.
The file that the book is talking about consists of records. There is, ofcourse, a finite number of records in the file. Normally, the file ends after the last record. The method returns false if the end of the file has been reached and there are no more records to read (this is the normal, expected end-of-file situation).
However, something could be wrong with the file. If the file ends in the middle of a record, then something is wrong. In a normal situation, this is not what's supposed to happen, so it's an unexpected end-of-file. In that case the method throws an exception, to indicate that something is wrong.