Here you can find the source of copyStreamToFile(InputStream in, File target)
public static boolean copyStreamToFile(InputStream in, File target)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; public class Main { /** Copy the contents of the given inputstream to given targetfile. * The inputstream in closed after copy. *//*from ww w. j av a 2 s . c om*/ public static boolean copyStreamToFile(InputStream in, File target) { try { OutputStream out = new FileOutputStream(target); byte[] buf = new byte[16384]; int c; while ((c = in.read(buf)) != -1) out.write(buf, 0, c); in.close(); return true; } catch (Exception e) { System.out.println("copyStreamToFile:" + e); return false; } } }