@Override
	public int read() throws IOException {
		int data = super.read();
		if (data == -1) return -1;

		if (streamPosition >= startingPosition && streamPosition <= endingPosition) {
			block[blockPosition++] = (byte)data;
		}

		streamPosition++;
		return data;
	}
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