Java Base64 Encode toBase64(final String str)

Here you can find the source of toBase64(final String str)

Description

Convert a String into its base64 representation.

License

Apache License

Parameter

Parameter Description
str The String to encode.

Return

The encoded .

Declaration

public static String toBase64(final String str) 

Method Source Code

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

import java.util.Base64;

public class Main {
    /**//  ww w  .  ja v a2s .com
     * Convert a {@code String} into its base64 representation.
     *
     * @param str
     *            The {@code String} to encode.
     * @return The encoded {@link String}.
     */
    public static String toBase64(final String str) {
        final String res64 = Base64.getEncoder().encodeToString(str.getBytes());
        return (res64);
    }
}

Related

  1. toBase64(byte[] buf, int start, int length)
  2. toBase64(byte[] data)
  3. toBase64(byte[] data)
  4. toBase64(final byte[] bytes)
  5. toBase64(final byte[] value)
  6. toBase64(int x)
  7. toBase64(long num)
  8. toBase64(long value)
  9. toBase64(String value)