Example usage for java.io CharArrayReader read

List of usage examples for java.io CharArrayReader read

Introduction

In this page you can find the example usage for java.io CharArrayReader read.

Prototype

public int read(char b[], int off, int len) throws IOException 

Source Link

Document

Reads characters into a portion of an array.

Usage

From source file:Main.java

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

    char[] ch = { 'H', 'E', 'L', 'L', 'O' };

    char[] d = new char[5];

    CharArrayReader car = new CharArrayReader(ch);

    // read character to the destination buffer
    car.read(d, 3, 2);

    // for every character in the buffer
    for (char c : d) {
        int i = (int) c;
        if (i == 0) {
            System.out.println("0");
        } else {/*from w w w .j  av  a2 s . c  om*/
            System.out.println(c);
        }
    }

}