Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

the argument of method mark() does not work  RSS feed

 
Kevin Lee
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!