base64 encoding String From String - Android File Input Output

Android examples for File Input Output:Base64

Description

base64 encoding String From String

Demo Code


//package com.java2s;
import android.util.Base64;
import java.io.UnsupportedEncodingException;

public class Main {
    public static String base64StringFromString(String startingString) {
        byte[] data = null;
        try {//from   w ww.j  a va2s  .c  o  m
            data = startingString.getBytes("UTF-8");
        } catch (UnsupportedEncodingException e1) {
            e1.printStackTrace();
        }
        return Base64.encodeToString(data, Base64.NO_WRAP
                | Base64.NO_PADDING);
    }
}

Related Tutorials