Java Dump Stream dumpInputOutputStream(InputStream is, OutputStream os)

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

Description

Dumps all bytes from an input stream to the given output stream.

License

EUPL

Parameter

Parameter Description
is the input stream to dump from.
os the output stream to dump to.

Exception

Parameter Description
IOException if an error occurs while dumping.

Declaration

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

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright 2014 Federal Chancellery Austria
 * MOA-ID has been developed in a cooperation between BRZ, the Federal
 * Chancellery Austria - ICT staff unit, and Graz University of Technology.
 * /*from   w  w w.ja va2s. c om*/
 * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
 * the European Commission - subsequent versions of the EUPL (the "Licence");
 * You may not use this work except in compliance with the Licence.
 * You may obtain a copy of the Licence at:
 * http://www.osor.eu/eupl/
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the Licence is distributed on an "AS IS" basis,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the Licence for the specific language governing permissions and
 * limitations under the Licence.
 * 
 * This product combines work with different licenses. See the "NOTICE" text
 * file for details on the various modules and licenses.
 * The "NOTICE" text file is part of the distribution. Any derivative works
 * that you distribute must include a readable copy of the "NOTICE" text file.
 ******************************************************************************/

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

public class Main {
    /**
     * Dumps all bytes from an input stream to the given output stream.
     * 
     * @param is
     *          the input stream to dump from.
     * @param os
     *          the output stream to dump to.
     * @throws IOException
     *           if an error occurs while dumping.
     */
    public static void dumpInputOutputStream(InputStream is, OutputStream os)
            throws IOException {
        if (is == null) {
            return;
        }
        int ch;
        while ((ch = is.read()) != -1) {
            os.write(ch);
        }
    }
}

Related

  1. dumpArray(PrintStream out, Object[] array)
  2. dumpEvent(String event, OutputStream stream)
  3. dumpFile(InputStream file, String header, String testName)
  4. dumpFile(JarInputStream jin, File targetFile)
  5. dumpFile(String r_file, OutputStream outputstream)
  6. dumpInputStream(InputStream instream)
  7. dumpInputStream(InputStream is, PrintStream p)
  8. dumpInputStream(InputStream stream)
  9. dumpInputStreamAsString(InputStream is)