@Override
    public void close() throws IOException {
        // If not already closed, then close the input stream.
        if(!this.closed) {
            this.closed = true;
            // if the user read to the end of the virtual stream, then drain
            // the wrapped stream so the HTTP client can keep this connection
            // alive if possible.
            // This should not have too much overhead since if we've reached the
            // end of the virtual stream, there should be at most 31 bytes left
            // (2 * JceEncryptionConstants.SYMMETRIC_CIPHER_BLOCK_SIZE - 1) in the
            // stream.
            // See: S3CryptoModuleBase#getCipherBlockUpperBound
             if (this.virtualAvailable == 0) {
                 IOUtils.drainInputStream(decryptedContents);
            }
            this.decryptedContents.close();
        }
        abortIfNeeded();
    }
Skip to the start location of the range of bytes desired by the user.
aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/internal/crypto/AdjustedRangeInputStream.java