Read characters into a portion of an array.
int bbuflen = len;
if (bbuflen > BBUF_LEN) {
bbuflen = BBUF_LEN;
}
byte bbuf[] = new byte[bbuflen];
int count = 0;
while(count < len) {
int nbytes = len - count;
if (nbytes > bbuflen) {
nbytes = bbuflen;
}
nbytes = in.read(bbuf, 0, nbytes);
if (nbytes == -1) {
return (count == 0) ? -1 : count;
}
for (int i=0; i<nbytes; i++) {
cbuf[off++] = (char)(bbuf[i] & 0xff);
}
count += nbytes;
}
return len;