Java IO Tutorial - Java StringWriter.write(char[] cbuf, int off, int len)








Syntax

StringWriter.write(char[] cbuf, int off, int len) has the following syntax.

public void write(char[] cbuf,  int off,  int len)

Example

In the following code shows how to use StringWriter.write(char[] cbuf, int off, int len) method.

//  w  ww. j a  v a2s .com
import java.io.*;

public class Main {

   public static void main(String[] args) {

      char c = 'b';
      
      StringWriter sw = new StringWriter();

      // write chars
      sw.write('a');
      sw.write(c);

      
      System.out.println(sw.toString());


   }
}

The code above generates the following result.