Here you can find the source of writeStreamToFile(InputStream in, OutputStream out)
public static void writeStreamToFile(InputStream in, OutputStream out) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static void writeStreamToFile(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[16384]; while (true) { int count = in.read(buffer); if (count < 0) break; out.write(buffer, 0, count); }//from w ww . jav a 2 s. c o m in.close(); out.close(); } }