Reading Writing Text  «Prev  Next»


Lesson 6The skip() and close() methods of the Reader class
ObjectiveExamine the methods of the Reader class for skipping characters and closing files.

Java skip() and close() Methods

skip( ) method

You can skip a certain number of characters with the skip() method. This method also blocks until some characters are available. It returns the number of characters skipped or -1 if the end-of-stream is reached.

public long skip(long n) throws IOException

The close( ) method

The close() method closes the Reader and releases any resources associated with it.
public abstract void close() throws IOException