Skip to content

Commit cc1fa94

Browse files
committed
support concated stream
1 parent b69d567 commit cc1fa94

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/java/net/jpountz/lz4/LZ4BlockInputStream.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ public LZ4BlockInputStream(InputStream in) {
9090

9191
@Override
9292
public int available() throws IOException {
93+
if (o == originalLen) {
94+
refill();
95+
}
9396
return originalLen - o;
9497
}
9598

@@ -147,7 +150,12 @@ public long skip(long n) throws IOException {
147150
}
148151

149152
private void refill() throws IOException {
150-
readFully(compressedBuffer, HEADER_LENGTH);
153+
try {
154+
readFully(compressedBuffer, HEADER_LENGTH);
155+
} catch (EOFException e) {
156+
finished = true;
157+
return;
158+
}
151159
for (int i = 0; i < MAGIC_LENGTH; ++i) {
152160
if (compressedBuffer[i] != MAGIC[i]) {
153161
throw new IOException("Stream is corrupted");
@@ -175,7 +183,7 @@ private void refill() throws IOException {
175183
if (check != 0) {
176184
throw new IOException("Stream is corrupted");
177185
}
178-
finished = true;
186+
refill();
179187
return;
180188
}
181189
if (buffer.length < originalLen) {

0 commit comments

Comments
 (0)