Like input streams, buffers can be marked and reset using the mark( ) and reset( ) methods:
public final Buffer mark( ) public final Buffer reset( ) throws InvalidMarkException
Initially, the mark is unset. Invoking the buffer's mark( ) method places the mark at the buffer's current position. Resetting returns the position to the previous mark. Unlike with InputStream, there's no markSupported( ) method. All buffers support marking and resetting.
The mark is always less than or equal to the position and the limit. If either the limit or the position is set to a value less than the current mark, the mark is cleared. Resetting when there's no mark throws an InvalidMarkException.
Streams in Memory
The File System
Working with Files
File Dialogs and Choosers
Character Sets and Unicode
Readers and Writers
Formatted I/O with java.text
The Java Communications API
The J2ME Generic Connection Framework