Example usage for org.apache.commons.codec.binary ApacheBase64 decodeBase64

List of usage examples for org.apache.commons.codec.binary ApacheBase64 decodeBase64

Introduction

In this page you can find the example usage for org.apache.commons.codec.binary ApacheBase64 decodeBase64.

Prototype

public static byte[] decodeBase64(final byte[] base64Data) 

Source Link

Document

Decodes Base64 data into octets

Usage

From source file:com.jbirdvegas.mgerrit.dialogs.DiffDialog.java

private String workAroundBadBase(String baseString) {
    if (baseString == null) {
        return getContext().getString(R.string.return_was_null);
    }//from  w  ww.j a va2 s  .c  o m
    String failMessage = "Failed to decode Base64 using: ";
    try {
        return new String(ApacheBase64.decodeBase64(baseString));
    } catch (IllegalArgumentException badBase) {
        Log.e(TAG, failMessage + "org.apache.commons.codec.binary.ApacheBase64", badBase);
    }
    try {
        return new String(Base64.decode(baseString.getBytes(), Base64.URL_SAFE | Base64.NO_PADDING));
    } catch (IllegalArgumentException badBase) {
        Log.e(TAG, failMessage + "android.util.Base64", badBase);
    }
    try {
        return new String(Base64Coder.decode(baseString));
    } catch (IllegalArgumentException badBase) {
        Log.e(TAG, failMessage + "com.jbirdvegas.mgerrit.helpers.Base64Coder", badBase);
    }
    return getContext().getString(R.string.failed_to_decode_base64);
}