Example usage for android.util Base64 decode

List of usage examples for android.util Base64 decode

Introduction

In this page you can find the example usage for android.util Base64 decode.

Prototype

public static byte[] decode(byte[] input, int flags) 

Source Link

Document

Decode the Base64-encoded data in input and return the data in a new byte array.

Usage

From source file:Main.java

public static void decoderBase64File(String base64Code, String savePath) throws Exception {
    byte[] buffer = Base64.decode(base64Code, Base64.DEFAULT);
    FileOutputStream out = new FileOutputStream(savePath);
    out.write(buffer);//from   w ww .  jav a2  s.  c  o m
    out.close();
}

From source file:Main.java

public static Bitmap getBitmapFromBase64(String base64) {
    byte[] decodedString = Base64.decode(base64, Base64.DEFAULT);
    Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
    return decodedByte;
}

From source file:Main.java

public static Bitmap base64ToBitmap(String base64String) {
    byte[] imgBytes = Base64.decode(base64String, Base64.DEFAULT);

    return BitmapFactory.decodeByteArray(imgBytes, 0, imgBytes.length);
}

From source file:Main.java

public static Bitmap decodeBitmap(String imageString) {
    byte[] imageBytes = Base64.decode(imageString, Base64.DEFAULT);
    Bitmap bmp = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);

    return bmp;//from   www. j  a  va2s  . c om
}

From source file:Main.java

public static Bitmap base64ToBitmap(String base64String) {
    byte[] bytes = Base64.decode(base64String, Base64.DEFAULT);
    Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
    return bitmap;
}

From source file:Main.java

public static byte[] decode(String str) {
    return Base64.decode(str, Base64.DEFAULT);
}

From source file:Main.java

public static Bitmap decodeBase64Image(String encodedImage) {
    byte[] decodedString = Base64.decode(encodedImage, Base64.DEFAULT);
    return BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
}

From source file:Main.java

public static Object StringToObject(String str) throws Exception {
    byte[] data = Base64.decode(str, 0);
    ObjectInputStream objectInputStream = new ObjectInputStream(new ByteArrayInputStream(data));
    Object object = objectInputStream.readObject();
    objectInputStream.close();/*from   w  ww . j  a v a 2  s . c o  m*/
    return object;
}

From source file:Main.java

public static Bitmap decodeBase64(String input) {
    try {//from   w w w . j a  va 2 s . c  o  m
        byte[] decodedBytes = Base64.decode(input, Base64.DEFAULT);
        return BitmapFactory.decodeByteArray(decodedBytes, 0, decodedBytes.length);
    } catch (IllegalArgumentException e) {
        return null;
    }
}

From source file:Main.java

public static byte[] decodeToByte(String content) {
    if (TextUtils.isEmpty(content)) {
        return null;
    }/*from  w  ww .  j av a  2 s .  com*/
    return Base64.decode(content.getBytes(), Base64.DEFAULT);
}