Java PushbackReader.read(char[] cbuf, int off, int len)
Syntax
PushbackReader.read(char[] cbuf, int off, int len) has the following syntax.
public int read(char[] cbuf, int off, int len) throws IOException
Example
In the following code shows how to use PushbackReader.read(char[] cbuf, int off, int len) method.
//from ww w . j a v a 2 s . c om
import java.io.*;
public class Main {
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 {
System.out.println(pr.read(cbuf));
System.out.println(cbuf);
pr.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »