This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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: 24183
    
  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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: the argument of method mark() does not work