File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

the argument of method mark() does not work

 
Kevin Lee
Greenhorn
Posts: 4
  • 0
  • 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
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • 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
  • 0
  • 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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic