Java tutorial
//package com.java2s; import android.util.Log; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { private static final String TAG = "FileUtils"; public static void writeFile(InputStream in, File file) throws IOException { Log.d(TAG, "write file=====start=="); if (!file.getParentFile().exists()) file.getParentFile().mkdirs(); if (file != null && file.exists()) file.delete(); FileOutputStream out = new FileOutputStream(file); byte[] buffer = new byte[1024 * 128]; int len = -1; while ((len = in.read(buffer)) != -1) { out.write(buffer, 0, len); } Log.d(TAG, "write file====success==="); out.flush(); out.close(); in.close(); } }