• 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

the argument of method mark() does not work

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I think the mark should get invalid after statement "System.out.println((char)br.read());
System.out.println((char)br.read());"
because the argument of method mark(2) is "2".but when I call reset(),the stream go to the position where I marked ,it seems mark will never be valid no matter how many byte have been read.
anybody call explain it ?
thanks
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

The Javadoc says (emphasis mine


After reading this many characters, attempting to reset the stream may fail.



The actual limit may be larger than the argument to mark(); I'd guess that the actual limit is a function of the buffer size and the amount remaining in the buffer when you call "mark()". But in any case, you can't depend on failure at a specific point; rather, you must guard against failure after a specific point. Get it?
 
Kevin Lee
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ernest Friedman-Hill:
Hi,

Welcome to JavaRanch!

The Javadoc says (emphasis mine



The actual limit may be larger than the argument to mark(); I'd guess that the actual limit is a function of the buffer size and the amount remaining in the buffer when you call "mark()". But in any case, you can't depend on failure at a specific point; rather, you must guard against failure after a specific point. Get it?


ok,I get it.thank you very much for your kind replay
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic