Java BufferedWriter.write(char[] cbuf, int off, int len)
Syntax
BufferedWriter.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 BufferedWriter.write(char[] cbuf, int off, int len) method.
/*w w w. java 2s . co m*/
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.StringWriter;
public class Main {
public static void main(String[] args) throws IOException {
char[] cbuf = "from java2s.com".toCharArray();
StringWriter sw = new StringWriter();
BufferedWriter bw = new BufferedWriter(sw);
bw.write(cbuf, 2, 5);
bw.flush();
StringBuffer sb = sw.getBuffer();
System.out.println(sb);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »