Class Base64
- 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 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 NullPointerException to be thrown.
- Since:
- 1.8
- External Specifications
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis class implements a decoder for decoding byte data using the Base64 encoding scheme as specified in RFC 4648 and RFC 2045.static classThis class implements an encoder for encoding byte data using the Base64 encoding scheme as specified in RFC 4648 and RFC 2045. -
Method Summary
Modifier and TypeMethodDescriptionstatic Base64.DecoderReturns aBase64.Decoderthat decodes using the Basic type base64 encoding scheme.static Base64.EncoderReturns aBase64.Encoderthat encodes using the Basic type base64 encoding scheme.static Base64.DecoderReturns aBase64.Decoderthat decodes using the MIME type base64 decoding scheme.static Base64.EncoderReturns aBase64.Encoderthat encodes using the MIME type base64 encoding scheme.static Base64.EncodergetMimeEncoder(int lineLength, byte[] lineSeparator) Returns aBase64.Encoderthat encodes using the MIME type base64 encoding scheme with specified line length and line separators.static Base64.DecoderReturns aBase64.Decoderthat decodes using the URL and Filename safe type base64 encoding scheme.static Base64.EncoderReturns aBase64.Encoderthat encodes using the URL and Filename safe type base64 encoding scheme.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Method Details
-
getEncoder
Returns aBase64.Encoderthat encodes using the Basic type base64 encoding scheme.- Returns:
- A Base64 encoder.
-
getUrlEncoder
Returns aBase64.Encoderthat encodes using the URL and Filename safe type base64 encoding scheme.- Returns:
- A Base64 encoder.
-
getMimeEncoder
Returns aBase64.Encoderthat encodes using the MIME type base64 encoding scheme.- Returns:
- A Base64 encoder.
-
getMimeEncoder
Returns aBase64.Encoderthat encodes using the 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 the rounded down line length is not a positive value, the output will not be separated in lineslineSeparator- the line separator for each output line- Returns:
- A Base64 encoder.
- Throws:
IllegalArgumentException- iflineSeparatorincludes any character of "The Base64 Alphabet" as specified in Table 1 of RFC 2045.
-
getDecoder
Returns aBase64.Decoderthat decodes using the Basic type base64 encoding scheme.- Returns:
- A Base64 decoder.
-
getUrlDecoder
Returns aBase64.Decoderthat decodes using the URL and Filename safe type base64 encoding scheme.- Returns:
- A Base64 decoder.
-
getMimeDecoder
Returns aBase64.Decoderthat decodes using the MIME type base64 decoding scheme.- Returns:
- A Base64 decoder.
-