• 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

mark () in FileInputStream

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you .
I tried the mark and got the concept.
reply
    Bookmark Topic Watch Topic
  • New Topic