public class Base64
extends java.lang.Object
Base64
provides Base64 encoding/decoding of strings and streams.Modifier and Type | Method and Description |
---|---|
static long |
calcEncodedLength(long dataLength)
Calculates the size (i.e.
|
static void |
decode(char[] chars,
int off,
int len,
java.io.OutputStream out)
Decode base64 encoded data.
|
static void |
decode(char[] chars,
java.io.OutputStream out)
Decode base64 encoded data.
|
static void |
decode(java.io.InputStream in,
java.io.OutputStream out)
Decode base64 encoded data.
|
static void |
decode(java.io.Reader reader,
java.io.OutputStream out)
Decode base64 encoded data.
|
static java.lang.String |
decode(java.lang.String data)
Decodes a base64-encoded string using the UTF-8 character encoding.
|
static void |
decode(java.lang.String data,
java.io.OutputStream out)
Decode base64 encoded data.
|
static java.lang.String |
decodeIfEncoded(java.lang.String data)
Decodes a base64-encoded string marked by a "{base64}" prefix.
|
static java.lang.String |
decodeOrEncode(java.lang.String data)
Base64-decodes or -encodes the given string, depending on whether
or not it contains a "{base64}" prefix.
|
static void |
encode(byte[] data,
int off,
int len,
java.io.Writer writer)
Outputs base64 representation of the specified data to a
Writer . |
static void |
encode(java.io.InputStream in,
java.io.OutputStream out)
Outputs base64 representation of the specified stream data to an
OutputStream . |
static void |
encode(java.io.InputStream in,
java.io.Writer writer)
Outputs base64 representation of the specified stream data to a
Writer . |
static java.lang.String |
encode(java.lang.String data)
Returns the base64 representation of UTF-8 encoded string.
|
static long |
guessDecodedLength(long encLength)
Pessimistically guesses the size (i.e.
|
static void |
main(java.lang.String[] args)
Base64-decodes or -encodes (see
decodeOrEncode(String)
all the given arguments and prints the results on separate lines
in standard output. |
public static void main(java.lang.String[] args)
decodeOrEncode(String)
all the given arguments and prints the results on separate lines
in standard output.args
- command line arguments to be decoded or encodedpublic static java.lang.String decodeOrEncode(java.lang.String data)
data
- string to be decoded or encodedpublic static java.lang.String decodeIfEncoded(java.lang.String data)
null
, then null
is returned.data
- string to be decoded, can be null
public static long calcEncodedLength(long dataLength)
dataLength
- length (i.e. number of bytes) of the data to be encodedpublic static long guessDecodedLength(long encLength)
encLength
- length (i.e. number of bytes) of the base64 encoded datapublic static void encode(java.io.InputStream in, java.io.Writer writer) throws java.io.IOException
Writer
.in
- stream data to be encodedwriter
- writer to output the encoded datajava.io.IOException
- if an i/o error occurspublic static void encode(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
OutputStream
.in
- stream data to be encodedout
- stream where the encoded data should be written tojava.io.IOException
- if an i/o error occurspublic static void encode(byte[] data, int off, int len, java.io.Writer writer) throws java.io.IOException
Writer
.data
- data to be encodedoff
- offset within data at which to start encodinglen
- length of data to encodewriter
- writer to output the encoded datajava.io.IOException
- if an i/o error occurspublic static java.lang.String encode(java.lang.String data)
data
- the string to be encodedpublic static java.lang.String decode(java.lang.String data)
data
- the base64-encoded data to be decodedpublic static void decode(java.io.Reader reader, java.io.OutputStream out) throws java.io.IOException
reader
- reader for the base64 encoded data to be decodedout
- stream where the decoded data should be written tojava.io.IOException
- if an i/o error occurspublic static void decode(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
in
- inputstream of the base64 encoded data to be decodedout
- stream where the decoded data should be written tojava.io.IOException
- if an i/o error occurspublic static void decode(java.lang.String data, java.io.OutputStream out) throws java.io.IOException
data
- the base64 encoded data to be decodedout
- stream where the decoded data should be written tojava.io.IOException
- if an i/o error occurspublic static void decode(char[] chars, java.io.OutputStream out) throws java.io.IOException
chars
- the base64 encoded data to be decodedout
- stream where the decoded data should be written tojava.io.IOException
- if an i/o error occurspublic static void decode(char[] chars, int off, int len, java.io.OutputStream out) throws java.io.IOException
chars
- the base64 encoded data to be decodedoff
- offset within data at which to start decodinglen
- length of data to decodeout
- stream where the decoded data should be written tojava.io.IOException
- if an i/o error occursCopyright © 2010 - 2020 Adobe. All Rights Reserved