Android Base64 Decode decoderBase64File(String base64Code, String type)

Here you can find the source of decoderBase64File(String base64Code, String type)

Description

decoder Base File

Declaration

public static String decoderBase64File(String base64Code, String type) 

Method Source Code

//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 decoderBase64File(String base64Code, String type) {
        String sdStatus = Environment.getExternalStorageState();
        if (!sdStatus.equals(Environment.MEDIA_MOUNTED)) { 
            Log.i("TestFile",
                    "SD card is not avaiable/writeable right now.");
            return "unavailable";
        }/*from   w  w w .j  a va  2s  .  com*/
        File file = new File("/sdcard/myDoc/");
        if (!file.exists()) {
            file.mkdirs();
        }
        String name = "tempfile." + type;
        String filePath = "/sdcard/myDoc/" + name;
        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;
    }
}

Related

  1. decode(String s)
  2. decode(String str)
  3. fromBase64(String data)
  4. decodes(String base64)
  5. decodeBase64(String encodedString)
  6. decode(String data, OutputStream out)
  7. decode(Reader reader, OutputStream out)
  8. decode(char c)
  9. decode(String s, OutputStream os)