GeeCON Prague 2014*
The moose likes I/O and Streams and the fly likes the argument of method mark() does not work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "the argument of method mark() does not work" Watch "the argument of method mark() does not work" New topic
Author

the argument of method mark() does not work

Kevin Lee
Greenhorn

Joined: Oct 06, 2007
Posts: 4

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
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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?


[Jess in Action][AskingGoodQuestions]
Kevin Lee
Greenhorn

Joined: Oct 06, 2007
Posts: 4
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
 
GeeCON Prague 2014
 
subject: the argument of method mark() does not work