in src/main/java/com/alibaba/com/caucho/hessian/io/HessianInput.java [1575:1631]
public InputStream readInputStream()
throws IOException {
int tag = read();
switch (tag) {
case 'N':
return null;
case 'B':
case 'b':
_isLastChunk = tag == 'B';
_chunkLength = (read() << 8) + read();
break;
default:
throw expect("inputStream", tag);
}
return new InputStream() {
boolean _isClosed = false;
@Override
public int read()
throws IOException {
if (_isClosed || _is == null)
return -1;
int ch = parseByte();
if (ch < 0)
_isClosed = true;
return ch;
}
@Override
public int read(byte[] buffer, int offset, int length)
throws IOException {
if (_isClosed || _is == null)
return -1;
int len = HessianInput.this.read(buffer, offset, length);
if (len < 0)
_isClosed = true;
return len;
}
@Override
public void close()
throws IOException {
while (read() >= 0) {
}
_isClosed = true;
}
};
}