• Post Reply Bookmark Topic Watch Topic
  • New Topic

mark () in FileInputStream

 
kumarth ravi
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written code for reading a file.



Here.textFile.txt file contains the following data.
abcdefgh

question
---------
when I run this code,IOException is thrown,that is mark/reset is not supported. How mark() function is works in FileInputStream.I need a simple example on mark and reset.


thanks in advance
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FileInputStream does not support mark().

You could find this out from the API documentation, although it's not super-obvious. Base class InputStream implements markSupported() to throw false and mark() to do nothing, so any subclass of InputStream that does not override markSupported() and mark() cannot support mark(). FileInputStream does not override them, so it cannot support mark().

BufferedInputStream does support mark(). Wrap your FileInputStream in one.
 
kumarth ravi
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you .
I tried the mark and got the concept.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!