Skip to content

Commit c4b947d

Browse files
committed
[CODEC-130] Base64InputStream.skip skips underlying stream, not output. Can skip more than Integer.MAX_VALUE at a time.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@1302652 13f79535-47bb-0310-9956-ffa450edef68
1 parent bc1c22b commit c4b947d

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,21 +163,17 @@ public long skip(long n) throws IOException {
163163

164164
// skip in chunks of 512 bytes
165165
final byte[] b = new byte[512];
166-
final int max = (int) Math.min(n, Integer.MAX_VALUE);
167-
int total = 0;
166+
long todo = n;
168167

169-
while (total < max) {
170-
int len = max - total;
171-
if (len > b.length) {
172-
len = b.length;
173-
}
174-
len = read(b, 0, len);
168+
while (todo > 0) {
169+
int len = (int) Math.min(b.length, todo);
170+
len = this.read(b, 0, len);
175171
if (len == EOF) {
176172
break;
177173
}
178-
total += len;
174+
todo -= len;
179175
}
180176

181-
return total;
177+
return n - todo;
182178
}
183179
}

0 commit comments

Comments
 (0)