Here you can find the source of decoderBase64FileWithFileName(String base64Code, String fileName)
public static String decoderBase64FileWithFileName(String base64Code, String fileName)
//package com.java2s; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import android.os.Environment; import android.util.Base64; import android.util.Log; public class Main { public static String decoderBase64FileWithFileName(String base64Code, String fileName) {//from w ww . ja va 2s . co m String sdStatus = Environment.getExternalStorageState(); if (!sdStatus.equals(Environment.MEDIA_MOUNTED)) { // ??sd???????? Log.i("TestFile", "SD card is not avaiable/writeable right now."); return "unavailable"; } File file = new File("/sdcard/myDoc/"); if (!file.exists()) { file.mkdirs(); } String filePath = "/sdcard/myDoc/" + fileName; byte[] buffer = Base64.decode(base64Code, Base64.DEFAULT); try { FileOutputStream out = new FileOutputStream(filePath); out.write(buffer); out.close(); } catch (IOException e) { e.printStackTrace(); } return filePath; } }