fix: read within limit #32

This commit is contained in:
REAndroid 2023-04-25 19:30:00 +02:00
parent c83645d82e
commit ce27a1bf4f

View File

@ -91,7 +91,12 @@ public class FileChannelInputStream extends InputStream {
if(this.bufferPosition < bufferLength){
return;
}
ByteBuffer byteBuffer = ByteBuffer.wrap(buffer);
int length = buffer.length;
long available = totalLength - position;
if(length > available){
length = (int) available;
}
ByteBuffer byteBuffer = ByteBuffer.wrap(buffer, 0, length);
bufferLength = fileChannel.read(byteBuffer);
bufferPosition = 0;
}