Java Byte Array to Base64 byteToBase64(byte[] data)

Here you can find the source of byteToBase64(byte[] data)

Description

From a byte[] returns a base 64 representation

License

Apache License

Parameter

Parameter Description
data byte[]

Exception

Parameter Description
IOException an exception

Return

String

Declaration

public static String byteToBase64(byte[] data) 

Method Source Code

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

import java.util.Base64;

public class Main {
    /**//  w  w  w .ja v  a2  s.  c  om
     * From a byte[] returns a base 64 representation
     * @param data byte[]
     * @return String
     * @throws IOException
     */
    public static String byteToBase64(byte[] data) {
        //BASE64Encoder encoder = new BASE64Encoder();
        //return encoder.encode(data);
        return Base64.getEncoder().encodeToString(data);
    }
}

Related

  1. byteArrayToBase64(byte[] a)
  2. bytesToBase64(byte[] bytes)
  3. bytesToBase64(byte[] bytes, int length)