Here you can find the source of saveStreamToFile(InputStream is, File destFile)
public static boolean saveStreamToFile(InputStream is, File destFile) throws IOException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static boolean saveStreamToFile(InputStream is, File destFile) throws IOException { FileOutputStream fos = new FileOutputStream(destFile); int readLen = 0; byte[] buf = new byte[1024]; while ((readLen = is.read(buf)) != -1) { System.out.println(readLen); fos.write(buf, 0, readLen);/*from www.j a va 2 s .c om*/ } fos.flush(); fos.close(); is.close(); return true; } }