Here you can find the source of writeStreamToStream(InputStream inputStream, OutputStream outputStream)
private static void writeStreamToStream(InputStream inputStream, OutputStream outputStream) 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 { private static void writeStreamToStream(InputStream inputStream, OutputStream outputStream) throws IOException { BufferedInputStream bis = new BufferedInputStream(inputStream); BufferedOutputStream bos = new BufferedOutputStream(outputStream); try {/*from w w w. j a v a 2 s .c o m*/ int i = 0; while ((i = bis.read()) != -1) { bos.write(i); } } finally { if (bis != null) { bis.close(); } if (bos != null) { bos.close(); } } } }