Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

expected end of file and unexpected end of file

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,,,

What does it mean ?
 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where do you read it? Can you post the url from where you read it?
 
Java Daisuki
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This section is found in my textbook called Computig concepts with Java essential from Cay Horstmann, John Wiley and son Inc.

Quote :
 
Java Daisuki
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

This section does not make sense to me.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't listen to Steve. Just read this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic