Java tutorial
//package com.java2s; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import android.content.Context; import android.util.Log; public class Main { private static final String TAG = "CommonUtils"; public static void writeInputStreamToFile(InputStream is, String fileName, Context context) throws FileNotFoundException, IOException { FileOutputStream fos = null; try { fos = context.openFileOutput(fileName, Context.MODE_PRIVATE); byte buf[] = new byte[1024]; int len = 0; while ((len = is.read(buf)) > 0) { fos.write(buf, 0, len); } fos.close(); } catch (Exception exp) { Log.v(TAG, "Failed to write to file exp:" + exp.getMessage()); exp.printStackTrace(); } } }