@Override
	public int read(byte[] b, int off, int len) throws IOException {
		int bytesRead = super.read(b, off, len);
		if (bytesRead == -1) return -1;

		if (streamPosition + bytesRead >= startingPosition && streamPosition <= endingPosition) {
			for (int i = 0; i < bytesRead; i++) {
				if (streamPosition + i >= startingPosition && streamPosition + i < endingPosition) {
					block[blockPosition++] = b[off + i];
				}
			}
		}

		streamPosition += bytesRead;
		return bytesRead;
	}
FilterInputStream that captures a range of bytes from a wrapped input stream.
aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/internal/crypto/ByteRangeCapturingInputStream.java