This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with available method  RSS feed

 
Sarikaa Bhatnagar
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am facing problem with the use of available method of fileinputstream.Its not returning the correct number of bytes that can be read from the input stream but returning a int less than the actual number of bytes available.

Can anyone help ?

Thanks,
Sarika.
 
Manuel Moons
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The available method returns the number of bytes that can be read without blocking. So it does not necessarily mean that the end of the stream is encountered.

Only when (available == -1) the end of the stream is reached.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!