Java PipedWriter.write(char[] cbuf, int off, int len)
Syntax
PipedWriter.write(char[] cbuf, int off, int len) has the following syntax.
public void write(char[] cbuf, int off, int len) throws IOException
Example
In the following code shows how to use PipedWriter.write(char[] cbuf, int off, int len) method.
import java.io.*;
//from w ww . j a va2 s . c o m
public class Main {
public static void main(String[] args) {
char[] c = {'h', 'e', 'l', 'l', 'o'};
PipedWriter writer = new PipedWriter();
PipedReader reader = new PipedReader();
try {
// connect the reader and the writer
writer.connect(reader);
writer.write(c, 0, 3);
// print what we wrote
for (int i = 0; i < 3; i++) {
System.out.println((char) reader.read());
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »