Java Dump Stream dumpStreamToStream(InputStream is, OutputStream os)

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

Description

Dump the input stream to the output stream.

License

Academic Free License

Parameter

Parameter Description
is a parameter
os a parameter

Declaration

public static void dumpStreamToStream(InputStream is, OutputStream os) 

Method Source Code

//package com.java2s;
//License from project: Academic Free License 

import java.io.InputStream;

import java.io.OutputStream;

public class Main {
    /**/*from   w  ww  . ja v a 2s  .c o m*/
     * Dump the input stream to the output stream.
     * 
     * @param is
     * @param os
     */
    public static void dumpStreamToStream(InputStream is, OutputStream os) {
        byte ba[] = new byte[2048];
        int numRead = 0;
        try {
            numRead = is.read(ba);
            while (numRead > 0) {
                os.write(ba, 0, numRead);
                numRead = is.read(ba);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            if (os != null)
                try {
                    os.flush();
                } catch (Exception ex) {
                }
            ;
        }
    }
}

Related

  1. dumpMap(PrintStream out, Map Values)
  2. dumpStream(InputStream in, PrintStream dump, boolean closeIn)
  3. dumpStream(InputStream in, String file)
  4. dumpStreamAndReOffer(InputStream is)
  5. dumpStreamToFile(InputStream is, String filename)
  6. dumpThreads(PrintStream ps)
  7. dumpToFile(Object obj, OutputStream os)