# Base64

public class **Base64** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
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](http://www.ietf.org/rfc/rfc4648.txt) and
[RFC 2045](http://www.ietf.org/rfc/rfc2045.txt).

- **Basic**

  Uses "The Base64 Alphabet" as specified in Table 1 of
  RFC 4648 and RFC 2045 for encoding and decoding operation.
  The encoder does not add any line feed (line separator)
  character. The decoder rejects data that contains characters
  outside the base64 alphabet.
- **URL and Filename safe**

  Uses the "URL and Filename safe Base64 Alphabet" as specified
  in Table 2 of RFC 4648 for encoding and decoding. The
  encoder does not add any line feed (line separator) character.
  The decoder rejects data that contains characters outside the
  base64 alphabet.
- **MIME**

  Uses the "The Base64 Alphabet" as specified in Table 1 of
  RFC 2045 for encoding and decoding operation. The encoded output
  must be represented in lines of no more than 76 characters each
  and uses a carriage return `'\r'` followed immediately by
  a linefeed `'\n'` as the line separator. No line separator
  is added to the end of the encoded output. All line separators
  or other characters not found in the base64 alphabet table are
  ignored in decoding operation.

Unless otherwise noted, passing a `null` argument to a
method of this class will cause a `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html` to be thrown.

### Nested Class Summary

|---|---|---|---|
| class | [Base64.Decoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Decoder.html) || This class implements a decoder for decoding byte data using the Base64 encoding scheme as specified in RFC 4648 and RFC 2045. |
| class | [Base64.Encoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Encoder.html) || This class implements an encoder for encoding byte data using the Base64 encoding scheme as specified in RFC 4648 and RFC 2045. |

### Public Method Summary

|---|---|
| static [Base64.Decoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Decoder.html) | [getDecoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.html#getDecoder())() Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Decoder.html` that decodes using the [Basic](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64#basic) type base64 encoding scheme. |
| static [Base64.Encoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Encoder.html) | [getEncoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.html#getEncoder())() Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Encoder.html` that encodes using the [Basic](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64#basic) type base64 encoding scheme. |
| static [Base64.Decoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Decoder.html) | [getMimeDecoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.html#getMimeDecoder())() Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Decoder.html` that decodes using the [MIME](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64#mime) type base64 decoding scheme. |
| static [Base64.Encoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Encoder.html) | [getMimeEncoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.html#getMimeEncoder())() Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Encoder.html` that encodes using the [MIME](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64#mime) type base64 encoding scheme. |
| static [Base64.Encoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Encoder.html) | [getMimeEncoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.html#getMimeEncoder(int,%20byte[]))(int lineLength, byte\[\] lineSeparator) Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Encoder.html` that encodes using the [MIME](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64#mime) type base64 encoding scheme with specified line length and line separators. |
| static [Base64.Decoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Decoder.html) | [getUrlDecoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.html#getUrlDecoder())() Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Decoder.html` that decodes using the [URL and Filename safe](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64#url) type base64 encoding scheme. |
| static [Base64.Encoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Encoder.html) | [getUrlEncoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.html#getUrlEncoder())() Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Encoder.html` that encodes using the [URL and Filename safe](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64#url) type base64 encoding scheme. |

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

## Public Methods

#### public static [Base64.Decoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Decoder.html)
**getDecoder**
()

Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Decoder.html` that decodes using the
[Basic](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64#basic) type base64 encoding scheme.

##### Returns

- A Base64 decoder.

#### public static [Base64.Encoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Encoder.html)
**getEncoder**
()

Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Encoder.html` that encodes using the
[Basic](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64#basic) type base64 encoding scheme.

##### Returns

- A Base64 encoder.

#### public static [Base64.Decoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Decoder.html)
**getMimeDecoder**
()

Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Decoder.html` that decodes using the
[MIME](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64#mime) type base64 decoding scheme.

##### Returns

- A Base64 decoder.

#### public static [Base64.Encoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Encoder.html)
**getMimeEncoder**
()

Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Encoder.html` that encodes using the
[MIME](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64#mime) type base64 encoding scheme.

##### Returns

- A Base64 encoder.

#### public static [Base64.Encoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Encoder.html)
**getMimeEncoder**
(int lineLength, byte\[\] lineSeparator)

Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Encoder.html` that encodes using the
[MIME](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64#mime) type base64 encoding scheme
with specified line length and line separators.

##### Parameters

| lineLength | the length of each output line (rounded down to nearest multiple of 4). If `lineLength <= 0` the output will not be separated in lines |
| lineSeparator | the line separator for each output line |
|---|---|

##### Returns

- A Base64 encoder.

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if `lineSeparator` includes any character of "The Base64 Alphabet" as specified in Table 1 of RFC 2045. |
|---|---|

#### public static [Base64.Decoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Decoder.html)
**getUrlDecoder**
()

Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Decoder.html` that decodes using the
[URL and Filename safe](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64#url) type base64
encoding scheme.

##### Returns

- A Base64 decoder.

#### public static [Base64.Encoder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Encoder.html)
**getUrlEncoder**
()

Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64.Encoder.html` that encodes using the
[URL and Filename safe](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Base64#url) type base64
encoding scheme.

##### Returns

- A Base64 encoder.