Example usage for java.io FilterReader skip

List of usage examples for java.io FilterReader skip

Introduction

In this page you can find the example usage for java.io FilterReader skip.

Prototype

public long skip(long n) throws IOException 

Source Link

Document

Skips characters.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {

    int i = 0;//from   w  ww  .  ja va 2 s  . co  m

    // create new reader
    Reader r = new StringReader("from java2s.com");

    // create new filter reader
    FilterReader fr = new FilterReader(r) {
    };

    // read till the end of the filter reader
    while ((i = fr.read()) != -1) {
        // convert integer to character
        char c = (char) i;

        // prints
        System.out.println("Character read: " + c);

        // number of characters actually skipped
        long l = fr.skip(2);

        // prints
        System.out.println("Character skipped: " + l);
    }

}