001/**
002 * Copyright 2015 DuraSpace, Inc.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.fcrepo.http.commons.responses;
017
018import java.io.IOException;
019import java.io.InputStream;
020
021import org.apache.commons.io.input.BoundedInputStream;
022
023/**
024 * An {@link InputStream} that skips bytes and only returns the data up to a certain limit
025 *
026 * @author awoods
027 * @author ajs6f
028 */
029public class RangeRequestInputStream extends BoundedInputStream {
030
031    /**
032     * @param in the underlying input stream, or <code>null</code> if
033     *           this instance is to be created without an underlying stream.
034     * @param skip the number of bytes to skip at the beginning of the stream
035     * @param length the number of bytes from the inputstream to read
036     * @throws IOException if IO exception occurred
037     */
038    public RangeRequestInputStream(final InputStream in, final long skip, final long length) throws IOException {
039        super(in, length);
040        in.skip(skip);
041    }
042}