public int read(char[] cbuf,int off,int len) throws IOException {
  int num=0;
  int val;
  while (num < len) {
    if ((val=is.read()) < 0) {
      return (num != 0) ? num : -1;
    }
switch (val & 0xf0) {
case 0xc0:
case 0xd0:
      cbuf[off++]=(char)(((val & 0x1f) << 6) | (is.read() & 0x3f));
    break;
case 0xe0:
  cbuf[off++]=(char)(((val & 0x0f) << 12) | ((is.read() & 0x3f) << 6) | (is.read() & 0x3f));
break;
case 0xf0:
throw new UnsupportedEncodingException("UTF-32 (or UCS-4) encoding not supported.");
default :
cbuf[off++]=(char)val;
break;
}
num++;
}
return num;
}

public int read ( char [ ] cbuf , int off , int len ) throws IOException { int num = 0 ; int val ; while ( num < len ) { if ( ( val = is . read ( ) ) < 0 ) { return ( num != 0 ) ? num : - 1 ; } switch ( val & 0xf0 ) { case 0xc0 : case 0xd0 : cbuf [ off ++ ] = ( char ) ( ( ( val & 0x1f ) << 6 ) | ( is . read ( ) & 0x3f ) ) ; break ; case 0xe0 : cbuf [ off ++ ] = ( char ) ( ( ( val & 0x0f ) << 12 ) | ( ( is . read ( ) & 0x3f ) << 6 ) | ( is . read ( ) & 0x3f ) ) ; break ; case 0xf0 : throw new UnsupportedEncodingException ( "UTF-32 (or UCS-4) encoding not supported." ) ; default : cbuf [ off ++ ] = ( char ) val ; break ; } num ++ ; } return num ; }
reads characters into a portion of an array .
