@Override public int read(byte[] bytes, int off, int len) throws IOException { bytesReadPastMarkPoint += off; // Ensure we don't read beyond the segment length if (bytesReadPastMarkPoint + getRelativeMarkPoint() >= segmentLength) { return -1; } if (bytesReadPastMarkPoint + getRelativeMarkPoint() + len > segmentLength) { len = (int) (segmentLength - (bytesReadPastMarkPoint + getRelativeMarkPoint() + off)); } return super.read(bytes, off, len); }
/** * Checks how many bytes have been transferred since the last notification, and sends a notification * message if this number exceeds the minimum bytes transferred value. * * @param bytesTransmitted */ public void sendNotificationUpdate(long bytesTransmitted) { progressWatcher.updateBytesTransferred(bytesTransmitted); }
private long bytesToInt(byte[] b, int offset) { int low = bytesToShort(b, offset); int high = bytesToShort(b, offset + 2); return ((long)high << 16) | low; }
public int read() throws IOException { if (getDeflatedBufferAvail() == 0) { primeDeflateBuffer(); } if (EOFTail) { return -1; } else { return (int) deflatedBytes[bufferOffset++] & 0xFF; } }
@Override public void forceInterruptCalled() { if (interruptableInputStream != null) { interruptableInputStream.interrupt(); } } }
/** * @return * an estimate of the recent rate of bytes/second transfer speed. */ public long getBytesPerSecond() { return BytesProgressWatcher.calculateRecentByteRatePerSecond(progressWatchers); }
@Override public int available() throws IOException { // Nobody will ever need an input stream longer that 2^31 - 1 bytes... D'oh! long reallyAvailable = this.segmentLength - (bytesReadPastMarkPoint + getRelativeMarkPoint()); if (reallyAvailable > Integer.MAX_VALUE) { return Integer.MAX_VALUE; } return (int) reallyAvailable; }
@Override public int read() throws IOException { byte[] tmp = new byte[1]; int count = read(tmp); if (count != -1) { return tmp[0]; } else { return count; } }
@Override public int read() throws IOException { // Ensure we don't read beyond the segment length if (bytesReadPastMarkPoint + getRelativeMarkPoint() >= segmentLength) { return -1; } else { return super.read(); } }
public int available() throws IOException { if (EOFTail) { return -1; } else if (getDeflatedBufferAvail() == 0) { primeDeflateBuffer(); } return getDeflatedBufferAvail(); }
@Override public void forceInterruptCalled() { if (interruptableInputStream != null) { interruptableInputStream.interrupt(); } } }
/** * @return * an estimate of the recent rate of bytes/second transfer speed. */ public long getBytesPerSecond() { return BytesProgressWatcher.calculateRecentByteRatePerSecond(progressWatchers); }
@Override public int read() throws IOException { // Ensure we don't read beyond the segment length if (bytesReadPastMarkPoint + getRelativeMarkPoint() >= segmentLength) { return -1; } else { return super.read(); } }
public int available() throws IOException { if (EOFTail) { return -1; } else if (getDeflatedBufferAvail() == 0) { primeDeflateBuffer(); } return getDeflatedBufferAvail(); }
@Override public void forceInterruptCalled() { if (interruptableInputStream != null) { interruptableInputStream.interrupt(); } } }
@Override public int read(byte[] bytes, int off, int len) throws IOException { bytesReadPastMarkPoint += off; // Ensure we don't read beyond the segment length if (bytesReadPastMarkPoint + getRelativeMarkPoint() >= segmentLength) { return -1; } if (bytesReadPastMarkPoint + getRelativeMarkPoint() + len > segmentLength) { len = (int) (segmentLength - (bytesReadPastMarkPoint + getRelativeMarkPoint() + off)); } return super.read(bytes, off, len); }
@Override public void forceInterruptCalled() { if (interruptableInputStream != null) { interruptableInputStream.interrupt(); } } }
@Override public void forceInterruptCalled() { if (interruptableInputStream != null) { interruptableInputStream.interrupt(); } } }
@Override public void forceInterruptCalled() { if (interruptableInputStream != null) { interruptableInputStream.interrupt(); } } }
@Override public void forceInterruptCalled() { if (interruptableInputStream != null) { interruptableInputStream.interrupt(); } } }