Example usage for java.io PushbackReader read

List of usage examples for java.io PushbackReader read

Introduction

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

Prototype

public int read(java.nio.CharBuffer target) throws IOException 

Source Link

Document

Attempts to read characters into the specified character buffer.

Usage

From source file:Main.java

public static void main(String[] args) {

    String s = "from java2s.com";

    StringReader sr = new StringReader(s);

    PushbackReader pr = new PushbackReader(sr, 20);

    char cbuf[] = new char[5];

    try {//  www  .  jav a 2 s  .  com
        System.out.println(pr.read(cbuf));

        System.out.println(cbuf);

        pr.close();

    } catch (IOException ex) {
        ex.printStackTrace();
    }
}