@Status(stage=DEVELOPMENT, unitTests=COMPLETE) @Review(by="Kees Schotanus",at="2010-09-23",reason="Initial review") @Review(by="Kees Schotanus",at="2010-10-01",reason="Additional review since binary data and line breaks were handled incorrectly") public final class Base64 extends Object
Modifier and Type | Field and Description |
---|---|
static int |
MAXIMUM_ENCODED_LINE_LENGHT
Maximum line length of a Base64 encoded line according to RFC 2045.
|
static int |
NO_LINE_BREAKS_LENGTH
Constant line length to be used when Base64 encoded output should not contain line breaks.
|
Modifier and Type | Method and Description |
---|---|
static byte[] |
decode(byte[] input)
Decodes the supplied Base64 encoded input.
|
static byte[] |
decodeFromFile(String fileName)
Decodes the Base64 encoded data from the supplied fileName.
|
static void |
decodeToFile(byte[] input,
String fileName)
Decodes the supplied input to a file with the supplied fileName.
|
static byte[] |
encode(byte[] input,
int lineSize)
Encodes the supplied input to a Base64 encoding.
|
static byte[] |
encodeFromFile(String fileName,
int lineSize)
Encodes the information stored in the file identified by the supplied fileName.
|
static void |
encodeToFile(byte[] input,
String fileName,
int lineSize)
Encodes the supplied input to a file with the supplied fileName.
|
public static final int MAXIMUM_ENCODED_LINE_LENGHT
public static final int NO_LINE_BREAKS_LENGTH
public static byte[] encodeFromFile(String fileName, int lineSize) throws IOException
fileName
- The name of the file to decode the data from.lineSize
- The length of the lines in the encoded output, normally either 64 or 76 (but must be divisible by 4).
IOException
- When the unencoded file could not be read.NullPointerException
- When the supplied fileName is null.IllegalArgumentException
- When the supplied fileName is empty or when the supplied lineSize is not divisible by 4
or when the lineSize <= 0.encode(byte[], int)
public static void encodeToFile(byte[] input, String fileName, int lineSize) throws IOException
input
- The data to encode.fileName
- The name of the file to write the encoded data to.lineSize
- The length of the lines in the encoded output, normally either 64 or 76 (but must be divisible by 4).
IOException
- When the encoded bytes could not be written.NullPointerException
- When either the supplied input array or the supplied fileName is null.IllegalArgumentException
- When the supplied fileName is empty or when the supplied lineSize is not divisible by 4
or when the lineSize <= 0.encode(byte[], int)
public static byte[] encode(byte[] input, int lineSize)
input
- The input to encode.lineSize
- The length of the lines in the encoded output, normally either 64 or 76.
NullPointerException
- When the supplied input array is null.IllegalArgumentException
- When the supplied lineSize is not divisible by 4 or when the lineSize <= 0.public static byte[] decodeFromFile(String fileName) throws IOException
fileName
- The name of the file to decode the data from.IOException
- When the decoded bytes could not be read.NullPointerException
- When the supplied fileName is null.IllegalArgumentException
- When the supplied fileName is empty.decode(byte[])
public static void decodeToFile(byte[] input, String fileName) throws IOException
input
- The data to decode.fileName
- The name of the file to write the decoded data to.IOException
- When the decoded bytes could not be written.NullPointerException
- When either the supplied input array or the supplied fileName is null.IllegalArgumentException
- When the supplied fileName is empty.decode(byte[])
public static byte[] decode(byte[] input)
input
- The input to decode.NullPointerException
- When the supplied input array is null.IllegalArgumentException
- When the supplied input contains an invalid character.Copyright © 2008–2018. All rights reserved.