Top Description Fields Constructors Methods
org.apache.hc.client5.http.utils

public Class Base64

extends Object
Class Inheritance
Annotations
@Internal
Static Imports
java.util.Base64.getEncoder, .Base64.getMimeDecoder

Provide implementations of the Base64 conversion methods from Commons Codec, delegating to the Java Base64 implementation.

Only the features currently used by HttpClient are implemented here rather than all the features of Commons Codec.

Notes:

This class is intended as in interim convenience. Any new code should use `java.util.Base64` directly.

Field Summary

Modifier and TypeField and Description
private static final Base64
private static final byte[]

Constructor Summary

AccessConstructor and Description
public
Base64()

Return an instance of the Base64 codec that use the regular Base64 alphabet (as opposed to the URL-safe alphabet).

public
Base64(final int lineLength)

Creates a Base64 codec used for decoding and encoding in URL-unsafe mode.

Method Summary

Modifier and TypeMethod and Description
public byte[]
decode(final byte[] base64)

Decode Base64-encoded bytes to their original form, using specifications from this codec instance

public byte[]
decode(final String base64)

Decode a Base64 String to its original form, using specifications from this codec instance

public static byte[]
decodeBase64(final byte[] base64)

Decodes Base64 data into octets.

public static byte[]
decodeBase64(final String base64)

Decodes a Base64 String into octets.

public byte[]
encode(final byte[] value)

Encode bytes to their Base64 form, using specifications from this codec instance

public static byte[]
encodeBase64(final byte[] base64)

Encodes binary data using the base64 algorithm but does not chunk the output.

public static String
encodeBase64String(final byte[] bytes)

Encodes binary data using the base64 algorithm but does not chunk the output.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CODECback to summary
private static final Base64 CODEC
EMPTY_BYTESback to summary
private static final byte[] EMPTY_BYTES

Constructor Detail

Base64back to summary
public Base64()

Return an instance of the Base64 codec that use the regular Base64 alphabet (as opposed to the URL-safe alphabet). Note that unlike the Commons Codec version, thus class will NOT decode characters from URL-safe alphabet.

Base64back to summary
public Base64(final int lineLength)

Creates a Base64 codec used for decoding and encoding in URL-unsafe mode.

As HttpClient never uses a non-zero length, this feature is not implemented here.

Method Detail

decodeback to summary
public byte[] decode(final byte[] base64)

Decode Base64-encoded bytes to their original form, using specifications from this codec instance

decodeback to summary
public byte[] decode(final String base64)

Decode a Base64 String to its original form, using specifications from this codec instance

decodeBase64back to summary
public static byte[] decodeBase64(final byte[] base64)

Decodes Base64 data into octets.

Note

this method does NOT accept URL-safe encodings

decodeBase64back to summary
public static byte[] decodeBase64(final String base64)

Decodes a Base64 String into octets.

Note

this method does NOT accept URL-safe encodings

encodeback to summary
public byte[] encode(final byte[] value)

Encode bytes to their Base64 form, using specifications from this codec instance

encodeBase64back to summary
public static byte[] encodeBase64(final byte[] base64)

Encodes binary data using the base64 algorithm but does not chunk the output.

encodeBase64Stringback to summary
public static String encodeBase64String(final byte[] bytes)

Encodes binary data using the base64 algorithm but does not chunk the output.