Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Copyright 2013-2015, Inc. or its affiliates. All Rights Reserved.
  * Licensed under the Apache License, Version 2.0 (the "License").
  * You may not use this file except in compliance with the License.
  * A copy of the License is located at
 * or in the "license" file accompanying this file. This file is distributed
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
package com.amazonaws.internal;
Base class for AWS Java SDK specific
public class SdkDigestInputStream extends DigestInputStream implements
        MetricAwareReleasable {
    private static final int SKIP_BUF_SIZE = 2*1024;
    public SdkDigestInputStream(InputStream streamMessageDigest digest) {
    public final boolean isMetricActivated() {
        if ( instanceof MetricAware) {
            MetricAware metricAware = (MetricAware);
            return metricAware.isMetricActivated();
        return false;
Skips over and discards n bytes of data from this input stream, while taking the skipped bytes into account for digest calculation. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. The actual number of bytes skipped is returned. If n is negative, no bytes are skipped.

The skip method of this class creates a byte array and then repeatedly reads into it until n bytes have been read or the end of the stream has been reached. Subclasses are encouraged to provide a more efficient implementation of this method. For instance, the implementation may depend on the ability to seek.

n the number of bytes to be skipped.
the actual number of bytes skipped.
Throws: if the stream does not support seek, or if some other I/O error occurs.
    public final long skip(final long nthrows IOException {
        if (n <= 0)
            return n;
        byte[] b = new byte[(int)Math.min(n)];
        long m = n// remaining number of bytes to read
        while (m > 0) {
            int len = read(b, 0, (int)Math.min(mb.length));
            if (len == -1)
                return (m == n) ? -1 : (n - m);
            m -= len;
        assert (m == 0);
        return n;
    public final void release() {
        // Don't call IOUtils.release(in, null) or else could lead to infinite loop
        if ( instanceof Releasable) {
            // This allows any underlying stream that has the close operation
            // disabled to be truly released
            Releasable r = (Releasable);
New to GrepCode? Check out our FAQ X