Skip to content

Commit 2f1f38a

Browse files
author
Niall Pemberton
committed
IO-197 Change size and position from int to long
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1002432 13f79535-47bb-0310-9956-ffa450edef68
1 parent 8c7fe8b commit 2f1f38a

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/java/org/apache/commons/io/input/BoundedInputStream.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ public class BoundedInputStream extends InputStream {
3838
private final InputStream in;
3939

4040
/** the max length to provide */
41-
private final int max;
41+
private final long max;
4242

4343
/** the number of bytes already returned */
44-
private int pos = 0;
44+
private long pos = 0;
4545

4646
/** the marked position */
47-
private int mark = -1;
47+
private long mark = -1;
4848

4949
/** flag if close shoud be propagated */
5050
private boolean propagateClose = true;
@@ -59,7 +59,7 @@ public class BoundedInputStream extends InputStream {
5959
public BoundedInputStream(InputStream in, long size) {
6060
// Some badly designed methods - eg the servlet API - overload length
6161
// such that "-1" means stream finished
62-
this.max = (int) size;
62+
this.max = size;
6363
this.in = in;
6464
}
6565

@@ -117,8 +117,8 @@ public int read(byte[] b, int off, int len) throws IOException {
117117
if (max>=0 && pos>=max) {
118118
return -1;
119119
}
120-
int maxRead = max>=0 ? Math.min(len, max-pos) : len;
121-
int bytesRead = in.read(b, off, maxRead);
120+
long maxRead = max>=0 ? Math.min(len, max-pos) : len;
121+
int bytesRead = in.read(b, off, (int)maxRead);
122122

123123
if (bytesRead==-1) {
124124
return -1;

0 commit comments

Comments
 (0)