Here you can find the source of copyStream(InputStream is, OutputStream os)
public static void copyStream(InputStream is, OutputStream os) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { public static void copyStream(InputStream is, OutputStream os) throws IOException { byte[] buf = new byte[4096]; BufferedInputStream bis = new BufferedInputStream(is); BufferedOutputStream bos = new BufferedOutputStream(os); int s;//from w w w. ja va 2 s. c o m try { while ((s = bis.read(buf)) > 0) { bos.write(buf, 0, s); } } finally { try { bos.flush(); } catch (Exception var11) { ; } } } }