Improve project unzipping performance

This commit is contained in:
Lukas W
2024-08-02 12:43:47 +00:00
committed by Laurent Clouet
parent 0ff9689cd1
commit e380298cf9

View File

@@ -51,4 +51,25 @@ public class ChunkInputStream extends InputStream {
return result;
}
/// Improve throughput by offering method to read whole block of bytes at once
@Override public int read(byte[] b, int off, int len) throws IOException {
int bytesRead = -1;
while (bytesRead == -1) {
bytesRead = currentStream.read(b, off, len);
if (bytesRead == -1) {
try {
prepareNextChunk();
}
catch (NoSuchElementException e) {
/// This was the last chunk
return -1;
}
}
}
return bytesRead;
}
}