Here you can find the source of copyFile(InputStream input, File outputLocation)
public static File copyFile(InputStream input, File outputLocation) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static File copyFile(InputStream input, File outputLocation) throws IOException { if (!outputLocation.exists()) { outputLocation.createNewFile(); }/* ww w.j a v a2s . c o m*/ FileOutputStream dest = new FileOutputStream(outputLocation); int read = 0; byte[] bytes = new byte[1024]; while ((read = input.read(bytes)) != -1) { dest.write(bytes, 0, read); } return outputLocation; } }