public class Base64Codec extends Codec
There are several standard options for string conversion line breaks, defined
by the #Option
enum. You can also specify your own breaks and maximum
line length.
Conversion to byte arrays always ignores whitespace, and will also ignore any specified start/end/separation strings (the separation string may appear any where in the source string, the start/end strings must appear in their respective locations).
Modifier and Type | Class and Description |
---|---|
static class |
Base64Codec.Option
Different standard construction options: each value specifies a combination of
maximum line length and separator characters.
|
EMPTY_ARRAY
Constructor and Description |
---|
Base64Codec()
Default constructor; equivalent to using
#Option.UNBROKEN . |
Base64Codec(Base64Codec.Option option)
Constructs an instance using standard parameters.
|
Base64Codec(int lineLength,
byte[] separator)
Creates an instance that uses standard encoding, but custom line
length and separator.
|
Base64Codec(int lineLength,
String separator)
Creates an instance with custom line length and separator, where
the separator is specified as a string (and converted via UTF-8).
|
Modifier and Type | Method and Description |
---|---|
void |
decode(InputStream in,
OutputStream out)
Decodes a stream according to the rules of the codec.
|
void |
encode(InputStream in,
OutputStream out)
Encodes a stream according to the rules of the codec.
|
byte[] |
toBytes(String str)
Decodes the passed string and returns it as a byte array.
|
String |
toString(byte[] data)
Encodes the passed array and returns it as a string.
|
decode, decode, encode, encode, nextNonWhitespace, skipIfSeparator, wrapIfNeeded
public Base64Codec()
#Option.UNBROKEN
.public Base64Codec(Base64Codec.Option option)
public Base64Codec(int lineLength, String separator)
public Base64Codec(int lineLength, byte[] separator)
public void encode(InputStream in, OutputStream out)
Codec
public void decode(InputStream in, OutputStream out)
Codec
public String toString(byte[] data)
public byte[] toBytes(String str)