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

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

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


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

//from  w w  w.  jav a2  s . co m

public class Main {
  public static void main(String[] args) throws Exception {

    char[] ch = { 'H', 'E', 'L', 'L', 'O' };

    char[] d = new char[5];

    CharArrayReader car = new CharArrayReader(ch);

    // read character to the destination buffer, 3, 2);

    // for every character in the buffer
    for (char c : d) {
      int i = (int) c;
      if (i == 0) {
      } else {


The code above generates the following result.