Java Encode encodeUtf8AsBase64(String data)

Here you can find the source of encodeUtf8AsBase64(String data)

Description

encode Utf As Base

License

Apache License

Declaration

public static String encodeUtf8AsBase64(String data) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.UnsupportedEncodingException;

import com.google.common.io.BaseEncoding;

public class Main {
    public static final String UTF_8 = "UTF-8";

    public static String encodeUtf8AsBase64(String data) {
        return encodeAsBase64(decodeAsUtf8(data));
    }/*from www.  j a v a2s.  com*/

    public static String encodeAsBase64(byte[] bytes) {
        return new String(BaseEncoding.base64().encode(bytes));
    }

    public static byte[] decodeAsUtf8(String data) {
        try {
            return data.getBytes(UTF_8);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. encodeToTargetEncoding(String text, String sourceEncoding, String targetEncoding)
  2. encodeUint(OutputStream out, final long value)
  3. encodeUInt32(int value, OutputStream out)
  4. encodeUnknownString(String in, OutputStream os)
  5. encodeUTCTime(long time, OutputStream os)
  6. encodeVarUInt32(int unsignedValue, OutputStream outputStream)
  7. encodeVarUInt64(long unsignedValue, OutputStream outputStream)
  8. encodeWikiTag(String s)
  9. encodeXML(String input)