Java IO Tutorial - Java[] cbuf, int off, int len)

Syntax[] cbuf, int off, int len) has the following syntax.

public abstract int read(char[] cbuf, int off, int len)   throws IOException


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

// w ww  .j  av  a 2s  .co m

public class Main {

   public static void main(String[] args) {

      String s = "tutorial from";

      Reader reader = new StringReader(s);

      // create a char array to read chars into
      char cbuf[] = new char[5];

      try {
         // read characters into a portion of an array.
         System.out.println(, 0, 5));


      } catch (IOException ex) {

The code above generates the following result.