Here you can find the source of copyStream(InputStream is, OutputStream os)
Parameter | Description |
---|---|
is | a parameter |
os | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
static public void copyStream(InputStream is, OutputStream os) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { /**/*from w w w .j a v a2s . co m*/ * Copy data from an InputStream to an OutputStream. * * @param is * @param os * @throws IOException */ static public void copyStream(InputStream is, OutputStream os) throws IOException { copyStream(is, os, false); } /** * Copy data from an InputStream to an OutputStream. Close the OutputStream * after copying if closeOs is set to {@code true}. * * @param is * @param os * @param closeOs * @throws IOException */ static public void copyStream(InputStream is, OutputStream os, boolean closeOs) throws IOException { byte[] buf = new byte[8192]; int n; while ((n = is.read(buf, 0, 8192)) != -1) { os.write(buf, 0, n); } os.flush(); if (closeOs) os.close(); } }