Base64-encode the given data and return a newly allocated byte[] with the result. - Android File Input Output

Android examples for File Input Output:Base64

Description

Base64-encode the given data and return a newly allocated byte[] with the result.

Demo Code


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

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

    /**//from  w  w  w. j av  a  2 s .c  om
     * Base64-encode the given data and return a newly allocated
     * byte[] with the result.
     *
     * @param input  the data to encode
     * @param offset the position within the input array at which to
     *               start
     * @param len    the number of bytes of input to encode
     */
    public static byte[] encode(byte[] input, int offset, int len) {
        return Base64.encode(input, offset, len, BASE64_FLAG);
    }

    /**
     * Base64-encode the given data and return a newly allocated
     * byte[] with the result.
     *
     * @param input  the data to encode
     */
    public static byte[] encode(byte[] input) {
        return Base64.encode(input, BASE64_FLAG);
    }
}

Related Tutorials