Decode the Base64-encoded data in input and return the data in a new byte array. - Android File Input Output

Android examples for File Input Output:Base64

Description

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

Demo Code


//package com.java2s;
import android.util.Base64;

public class Main {
    private static final int BASE64_FLAG = Base64.NO_WRAP;

    /**/*from  w ww  . j av  a  2s.  c o  m*/
     * Decode the Base64-encoded data in input and return the data in
     * a new byte array.
     *
     * <p>The padding '=' characters at the end are not omitted
     *
     * @param input the input array to decode
     * @param offset the position within the input array at which to start
     * @param len    the number of bytes of input to decode
     *
     * @throws IllegalArgumentException if the input contains
     * incorrect padding
     */
    public static byte[] decode(byte[] input, int offset, int len) {
        return Base64.decode(input, offset, len, BASE64_FLAG);
    }

    /**
     * Decode the Base64-encoded data in input and return the data in
     * a new byte array.
     *
     * <p>The padding '=' characters at the end are not omitted
     *
     * @param input the input array to decode
     *
     * @throws IllegalArgumentException if the input contains
     * incorrect padding
     */
    public static byte[] decode(byte[] input) {
        return Base64.decode(input, BASE64_FLAG);
    }
}

Related Tutorials