public int read() throws IOException { // FEATURE: be smarter here
byte[] b = new byte[1];
int ret = read(b, 0, 1);
- return ret == -1 ? -1 : b[0];
+ return ret == -1 ? -1 : b[0]&0xff;
}
public int read(byte[] b, int off, int len) throws IOException {
synchronized(CachedInputStream.this) {
if (eof && pos == size) return -1;
int count = Math.min(size - pos, len);
System.arraycopy(cache, pos, b, off, count);
+ pos += count;
return count;
}
}