Optimize bulk reads from ByteArrayInputStream

This commit is contained in:
Eric Scharff 2007-10-30 15:08:49 -06:00
parent 958d39aa03
commit df79f410f1

View File

@ -19,6 +19,18 @@ public class ByteArrayInputStream extends InputStream {
}
}
public int read(byte[] buffer, int offset, int bufferLength) {
if (position < length) {
return -1;
}
if (length-position < bufferLength) {
bufferLength = length-position;
}
System.arraycopy(buffer, offset, array, position, bufferLength);
position += bufferLength;
return bufferLength;
}
public int available() {
return length - position;
}