Example usage for java.io CharArrayReader skip

List of usage examples for java.io CharArrayReader skip

Introduction

In this page you can find the example usage for java.io CharArrayReader 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 {

    char[] ch = { 'A', 'B', 'C', 'D', 'E' };

    CharArrayReader car = new CharArrayReader(ch);

    int value = 0;

    // read till the end of the stream
    while ((value = car.read()) != -1) {
        // convert integer to char
        char c = (char) value;

        // print characters
        System.out.print(c + "; ");

        // skip single character
        long l = car.skip(1);
        System.out.println("Characters Skipped : " + l);
    }/*w  ww  .j av a  2s . co m*/
}