• 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

What are the streams which at the end of file don't throws EOFException?

 
Ranch Hand
Posts: 226
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As for the subject: What are the streams which at the end of file don't throws EOFException?

Directly from this java oracle tutorial (Programme II level OCPJP7):


Notice that DataStreams detects an end-of-file condition by catching EOFException, instead of testing for an invalid return value. All implementations of DataInput methods use EOFException instead of return values.



I thought all the streams once reached the end of the file would throw an EOFException.

Which one does not?
Thanks in advance.


 
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It actually depends on the method being called rather than the actual stream type. As it said in your quote

All implementations of DataInput methods use EOFException instead of return values.


However not all streams implement the DataInput interface. They do all however extend the InputStream class (or wrap a class that does) and all methods of this class return -1 when they reach EOF.
 
Nick Widelec
Ranch Hand
Posts: 226
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stuart A. Burkett wrote:It actually depends on the method being called rather than the actual stream type. As it said in your quote

All implementations of DataInput methods use EOFException instead of return values.


However not all streams implement the DataInput interface. They do all however extend the InputStream class (or wrap a class that does) and all methods of this class return -1 when they reach EOF.[/quote

Ok I got confuse cause the DataInputStream has also the read() method which returns -1 at EOF however it's inherited from FilterInputStream.

Thanks for your time.

 
reply
    Bookmark Topic Watch Topic
  • New Topic