261 |
if (off < 0 || len < 0 || b.length - off < len) |
if (off < 0 || len < 0 || b.length - off < len) |
262 |
throw new IndexOutOfBoundsException(); |
throw new IndexOutOfBoundsException(); |
263 |
|
|
264 |
|
if (len == 0) |
265 |
|
return 0; |
266 |
|
|
267 |
if (pos >= count && !refill()) |
if (pos >= count && !refill()) |
268 |
return -1; // No bytes were read before EOF. |
return -1; // No bytes were read before EOF. |
269 |
|
|
321 |
public synchronized long skip(long n) throws IOException |
public synchronized long skip(long n) throws IOException |
322 |
{ |
{ |
323 |
if (buf == null) |
if (buf == null) |
324 |
throw new IOException("Stream closed."); |
throw new IOException("Stream closed."); |
325 |
|
|
326 |
final long origN = n; |
final long origN = n; |
327 |
|
|
328 |
while (n > 0L) |
while (n > 0L) |
329 |
{ |
{ |
330 |
if (pos >= count && !refill()) |
if (pos >= count && !refill()) |
331 |
if (n < origN) |
break; |
|
break; |
|
|
else |
|
|
return -1; // No bytes were read before EOF. |
|
332 |
|
|
333 |
int numread = (int) Math.min((long) (count - pos), n); |
int numread = (int) Math.min((long) (count - pos), n); |
334 |
pos += numread; |
pos += numread; |
347 |
private boolean refill() throws IOException |
private boolean refill() throws IOException |
348 |
{ |
{ |
349 |
if (buf == null) |
if (buf == null) |
350 |
throw new IOException("Stream closed."); |
throw new IOException("Stream closed."); |
351 |
|
|
352 |
if (markpos == -1 || count - markpos >= marklimit) |
if (markpos == -1 || count - markpos >= marklimit) |
353 |
{ |
{ |
371 |
int numread = super.read(buf, count, bufferSize); |
int numread = super.read(buf, count, bufferSize); |
372 |
|
|
373 |
if (numread <= 0) // EOF |
if (numread <= 0) // EOF |
374 |
return false; |
return false; |
375 |
|
|
376 |
count += numread; |
count += numread; |
377 |
return true; |
return true; |