Java InputStream to OutputStream copyStreamIoe(final InputStream is, final OutputStream os)

Here you can find the source of copyStreamIoe(final InputStream is, final OutputStream os)

Description

Copies the data from the given input stream into the given output stream and doesn't wrap any IOException .

License

Open Source License

Parameter

Parameter Description
is the InputStream
os the OutputStream

Exception

Parameter Description
IOException in an I/O error occurs

Declaration

public static void copyStreamIoe(final InputStream is, final OutputStream os) throws IOException 

Method Source Code

//package com.java2s;
/*/*  ww w .  j ava 2s  .  c  om*/
 * "Copyright (c) 2013   Capgemini Technology Services (hereinafter "Capgemini")
 *
 * License/Terms of Use
 * Permission is hereby granted, free of charge and for the term of intellectual
 * property rights on the Software, to any person obtaining a copy of this software
 * and associated documentation files (the "Software"), to use, copy, modify and
 * propagate free of charge, anywhere in the world, all or part of the Software
 * subject to the following mandatory conditions:
 *
 * -   The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * Any failure to comply with the above shall automatically terminate the license
 * and be construed as a breach of these Terms of Use causing significant harm to
 * Capgemini.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, PEACEFUL ENJOYMENT,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
 * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name of Capgemini shall not be used in
 * advertising or otherwise to promote the use or other dealings in this Software
 * without prior written authorization from Capgemini.
 *
 * These Terms of Use are subject to French law.
 *
 * IMPORTANT NOTICE: The WUIC software implements software components governed by
 * open source software licenses (BSD and Apache) of which CAPGEMINI is not the
 * author or the editor. The rights granted on the said software components are
 * governed by the specific terms and conditions specified by Apache 2.0 and BSD
 * licenses."
 */

import java.io.InputStream;

import java.io.IOException;
import java.io.OutputStream;

public class Main {
    /**
     * Length of a memory buffer used in WUIC.
     */
    public static final int WUIC_BUFFER_LEN = 2048;

    /**
     * <p>
     * Copies the data from the given input stream into the given output stream and doesn't wrap any {@code IOException}.
     * </p>
     *
     * @param is the {@code InputStream}
     * @param os the {@code OutputStream}
     * @throws IOException in an I/O error occurs
     */
    public static void copyStreamIoe(final InputStream is, final OutputStream os) throws IOException {
        int offset;
        final byte[] buffer = new byte[WUIC_BUFFER_LEN];

        while ((offset = is.read(buffer)) != -1) {
            os.write(buffer, 0, offset);
        }
    }
}

Related

  1. copyStreamAndClose(InputStream is, OutputStream os)
  2. copyStreamBounded(InputStream in, OutputStream out, long length)
  3. copyStreamContent(InputStream inputStream, OutputStream outputStream)
  4. copyStreamContent(InputStream inputStream, OutputStream outputStream)
  5. copyStreamFully(InputStream in, OutputStream out, int length)
  6. copyStreamNoClose(InputStream in, OutputStream out)
  7. copyStreamPortion(java.io.InputStream inputStream, java.io.OutputStream outputStream, int portionSize, int bufferSize)
  8. copyStreams(final InputStream in, final OutputStream out)
  9. copyStreams(final InputStream input, final OutputStream output)