Java tutorial
//package com.java2s; import android.util.Log; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static void writeStreamToFile(InputStream is, File file) { FileOutputStream fos = null; try { fos = new FileOutputStream(file); byte[] buffer = new byte[4096]; int length = 0; while ((length = is.read(buffer)) != -1) { fos.write(buffer, 0, length); fos.flush(); } Log.d("tg", "FileUtils writeStreamToFile successed..."); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } } } }