Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Detecting the end of a text file...  RSS feed

 
Landon Blake
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to detect the end of a text file wrapped by the java.io.BufferedReader class?

I didn't see a method in the Javadoc for this class or the superclass java.io.Reader that would let me do this. Is there a special character that marks the end of a text file?

Thanks,

Landon
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When readLine() returns null, there is no more text.
 
Ramen Chatterjee
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or -1 if using read() - both this and readLine() are documented in the API

Ramen
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!