This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
mark public void mark(int�readlimit) Marks the current position in this input stream. A subsequent call to the reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes. The readlimit arguments tells this input stream to allow that many bytes to be read before the mark position gets invalidated.
This little chunk of code might help you understand things a bit better:
Originally posted by Thiru Thangavelu: Thanks Jessica, How do you say mark(10) marks next character?
Read the API -- the int '10' doesn't have anything to do with which character gets marked. .mark(int) always marks the next character in the stream. The int parameter is the read limit -- it tells the input stream to allow that many bytes to be read before the mark position gets invalidated. So if you called stream.mark(2) and then read in 3 characters -- that mark would no longer be valid -- because you passed the readlimit. -- I believe if you call .reset() on an invalid mark, you will get an IOException.