Java String Encode encode(String str)

Here you can find the source of encode(String str)

Description

encode

License

Apache License

Declaration

public static String encode(String str) 

Method Source Code

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

import sun.misc.BASE64Encoder;
import java.io.UnsupportedEncodingException;

public class Main {
    public static String encode(String str) {
        byte[] b = null;
        String s = null;/*from  w w  w.j  ava2  s  . c  o m*/
        try {
            b = str.getBytes("utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        if (b != null) {
            s = new BASE64Encoder().encode(b);
        }
        return s;
    }
}

Related

  1. encode(String s, String enc)
  2. encode(String s, String encoding)
  3. encode(String source, String charsetFrom, String charsetTo)
  4. encode(String src)
  5. encode(String src, String charset)
  6. encode(String str, int start, int end, Writer writer)
  7. encode(String text, String charset)
  8. encode(String text, String encoding)
  9. encode(String text, String encoding)