Here you can find the source of inputStreamToOutputStream(InputStream inStream, OutputStream outStream)
public static void inputStreamToOutputStream(InputStream inStream, OutputStream outStream) throws IOException
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; public class Main { public static void inputStreamToOutputStream(InputStream inStream, OutputStream outStream) throws IOException { PrintWriter printWritter = new PrintWriter(new OutputStreamWriter(outStream)); BufferedReader bufReader = new BufferedReader(new InputStreamReader(inStream)); String line;//from w ww .j ava 2 s . c o m while ((line = bufReader.readLine()) != null) { printWritter.println(line); } printWritter.flush(); //outStream.flush(); } }