Here you can find the source of writeFile(InputStream is, File outFile)
public static void writeFile(InputStream is, File outFile) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static void writeFile(InputStream is, File outFile) throws IOException { BufferedOutputStream bos = null; try {//from w ww . j a v a 2 s . c o m bos = new BufferedOutputStream(new FileOutputStream(outFile)); byte[] buffer = new byte[4096]; int len; BufferedInputStream bis = new BufferedInputStream(is); while ((len = bis.read(buffer)) != -1) { bos.write(buffer, 0, len); } } finally { if (bos != null) { bos.close(); } } } public static void writeFile(byte[] buffer, File outFile) throws IOException { BufferedOutputStream bos = null; try { bos = new BufferedOutputStream(new FileOutputStream(outFile)); bos.write(buffer); } finally { if (bos != null) { bos.close(); } } } }