Here you can find the source of writeFile(File outputFile, InputStream inputStream)
public static void writeFile(File outputFile, InputStream inputStream)
//package com.java2s; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { public static void writeFile(File outputFile, InputStream inputStream) { try {/*from w ww .j a v a 2 s . c o m*/ // write the inputStream to a FileOutputStream OutputStream out = new FileOutputStream(outputFile); int read = 0; byte[] bytes = new byte[1024]; while ((read = inputStream.read(bytes)) != -1) { out.write(bytes, 0, read); } out.flush(); out.close(); } catch (IOException e) { System.out.println(e.getMessage()); } } }