Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static boolean putFileContent(File file, InputStream inputStream) throws IOException { if (!file.exists() && !file.createNewFile()) { return false; } byte[] buffer = new byte[1024]; FileOutputStream fileOutputStream = new FileOutputStream(file); for (int len; (len = inputStream.read(buffer)) != -1;) { fileOutputStream.write(buffer, 0, len); } inputStream.close(); fileOutputStream.close(); return true; } }