Java Base64 Encode base64Encode(String s)

Here you can find the source of base64Encode(String s)

Description

base Encode

License

Apache License

Declaration

public static String base64Encode(String s) 

Method Source Code

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

import java.io.UnsupportedEncodingException;

public class Main {
    private static final String DEFAULT_CHARSET = "utf-8";

    public static String base64Encode(String s) {
        if (s == null)
            return null;
        try {/*from   w  w  w  . j a va  2 s .  c  o  m*/
            return (new sun.misc.BASE64Encoder()).encode(s.getBytes(DEFAULT_CHARSET));
        } catch (UnsupportedEncodingException e) {
            return null;
        }
    }

    public static String base64Encode(byte[] data) {
        if (data == null || data.length == 0)
            return null;
        return (new sun.misc.BASE64Encoder()).encode(data);
    }
}

Related

  1. base64Encode(String plaintext)
  2. base64Encode(String plainTextString)
  3. base64Encode(String s)
  4. base64encode(String s)
  5. base64Encode(String s)
  6. base64encode(String str)
  7. base64Encode(String string)
  8. base64Encode(String string)
  9. base64encode(String text)