[ Web Proxy ]
URL:
Viewing: https://developer.android.com/reference/kotlin/java/util/Base64 [Back]  [Original]

Base64  |  API reference  |  Android Developers Skip to main content
Essentials Design & Plan Develop Google Play Blog
Search:
Android Studio
Android Developers [Android Developers]
Stay organized with collections Save and categorize content based on your preferences.
Added in API level 26

Base64

class Base64
kotlin.Any
java.util.Base64

This class consists exclusively of static methods for obtaining encoders and decoders for the Base64 encoding scheme. The implementation of this class supports the following types of Base64 as specified in RFC 4648 and RFC 2045.

Unless otherwise noted, passing a null argument to a method of this class will cause a NullPointerException to be thrown.

Summary

Nested classes

This class implements a decoder for decoding byte data using the Base64 encoding scheme as specified in RFC 4648 and RFC 2045.

This class implements an encoder for encoding byte data using the Base64 encoding scheme as specified in RFC 4648 and RFC 2045.

Public methods
static Base64.Decoder!

Returns a Decoder that decodes using the Basic type base64 encoding scheme.

static Base64.Encoder!

Returns a Encoder that encodes using the Basic type base64 encoding scheme.

static Base64.Decoder!

Returns a Decoder that decodes using the MIME type base64 decoding scheme.

static Base64.Encoder!

Returns a Encoder that encodes using the MIME type base64 encoding scheme.

static Base64.Encoder!
getMimeEncoder(lineLength: Int, lineSeparator: ByteArray!)

Returns a Encoder that encodes using the MIME type base64 encoding scheme with specified line length and line separators.

static Base64.Decoder!

Returns a Decoder that decodes using the URL and Filename safe type base64 encoding scheme.

static Base64.Encoder!

Returns a Encoder that encodes using the URL and Filename safe type base64 encoding scheme.

Public methods

getDecoder

Added in API level 26
static fun getDecoder(): Base64.Decoder!

Returns a Decoder that decodes using the Basic type base64 encoding scheme.

Return
Base64.Decoder! A Base64 decoder.

getEncoder

Added in API level 26
static fun getEncoder(): Base64.Encoder!

Returns a Encoder that encodes using the Basic type base64 encoding scheme.

Return
Base64.Encoder! A Base64 encoder.

getMimeDecoder

Added in API level 26
static fun getMimeDecoder(): Base64.Decoder!

Returns a Decoder that decodes using the MIME type base64 decoding scheme.

Return
Base64.Decoder! A Base64 decoder.

getMimeEncoder

Added in API level 26
static fun getMimeEncoder(): Base64.Encoder!

Returns a Encoder that encodes using the MIME type base64 encoding scheme.

Return
Base64.Encoder! A Base64 encoder.

getMimeEncoder

Added in API level 26
static fun getMimeEncoder(
    lineLength: Int,
    lineSeparator: ByteArray!
): Base64.Encoder!

Returns a Encoder that encodes using the MIME type base64 encoding scheme with specified line length and line separators.

Parameters
lineLength Int: the length of each output line (rounded down to nearest multiple of 4). If the rounded down line length is not a positive value, the output will not be separated in lines
lineSeparator ByteArray!: the line separator for each output line
Return
Base64.Encoder! A Base64 encoder.
Exceptions
java.lang.IllegalArgumentException if lineSeparator includes any character of "The Base64 Alphabet" as specified in Table 1 of RFC 2045.

getUrlDecoder

Added in API level 26
static fun getUrlDecoder(): Base64.Decoder!

Returns a Decoder that decodes using the URL and Filename safe type base64 encoding scheme.

Return
Base64.Decoder! A Base64 decoder.

getUrlEncoder

Added in API level 26
static fun getUrlEncoder(): Base64.Encoder!

Returns a Encoder that encodes using the URL and Filename safe type base64 encoding scheme.

Return
Base64.Encoder! A Base64 encoder.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2026-06-23 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-06-23 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page