-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#96 Read fully into buffer with retries
- Loading branch information
1 parent
04f0264
commit ca5e6f6
Showing
10 changed files
with
355 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/test/java/net/lingala/zip4j/testutils/ControlledReadInputStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package net.lingala.zip4j.testutils; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
public class ControlledReadInputStream extends InputStream { | ||
|
||
private InputStream inputStream; | ||
private int readLimit; | ||
private byte[] singleByteBuffer = new byte[1]; | ||
|
||
public ControlledReadInputStream(InputStream inputStream, int maximumNumberOfBytesToReadAtOnce) { | ||
this.inputStream = inputStream; | ||
this.readLimit = maximumNumberOfBytesToReadAtOnce; | ||
} | ||
|
||
@Override | ||
public int read() throws IOException { | ||
int readLen = read(singleByteBuffer); | ||
|
||
if (readLen == -1) { | ||
return -1; | ||
} | ||
|
||
return singleByteBuffer[0]; | ||
} | ||
|
||
@Override | ||
public int read(byte[] b) throws IOException { | ||
return read(b, 0, b.length); | ||
} | ||
|
||
@Override | ||
public int read(byte[] b, int off, int len) throws IOException { | ||
int toRead = len > readLimit ? readLimit : len; | ||
return inputStream.read(b, off, toRead); | ||
} | ||
} |
Oops, something went wrong.