Here you can find the source of inputStreamToFile(InputStream is, File targetFile)
public static void inputStreamToFile(InputStream is, File targetFile) 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; import java.io.OutputStream; import com.google.common.io.ByteStreams; public class Main { public static void inputStreamToFile(InputStream is, File targetFile) throws IOException { byte[] buffer = ByteStreams.toByteArray(is); OutputStream outStream = new FileOutputStream(targetFile); outStream.write(buffer);//from w w w .j a va2 s . c o m outStream.flush(); outStream.close(); } }