public class B64Code extends Object
Does not insert or interpret whitespace as described in RFC 1521. If you require this you must pre/post process your data.
Note that in a web context the usual case is to not want linebreaks or other white space in the encoded output.
Modifier and Type | Method and Description |
---|---|
static byte[] |
decode(char[] b)
Fast Base 64 decode as described in RFC 1421.
|
static byte[] |
decode(String encoded)
Base 64 decode as described in RFC 2045.
|
static void |
decode(String encoded,
ByteArrayOutputStream bout)
Base 64 decode as described in RFC 2045.
|
static String |
decode(String encoded,
Charset charEncoding)
Base 64 decode as described in RFC 2045.
|
static String |
decode(String encoded,
String charEncoding)
Base 64 decode as described in RFC 2045.
|
static char[] |
encode(byte[] b)
Fast Base 64 encode as described in RFC 1421.
|
static char[] |
encode(byte[] b,
boolean rfc2045)
Fast Base 64 encode as described in RFC 1421 and RFC2045
|
static void |
encode(int value,
Appendable buf) |
static void |
encode(long lvalue,
Appendable buf) |
static String |
encode(String s)
Base 64 encode as described in RFC 1421.
|
static String |
encode(String s,
Charset charEncoding)
Base 64 encode as described in RFC 1421.
|
static String |
encode(String s,
String charEncoding)
Base 64 encode as described in RFC 1421.
|
public static String encode(String s)
Does not insert whitespace as described in RFC 1521.
s
- String to encode.public static String encode(String s, String charEncoding)
Does not insert whitespace as described in RFC 1521.
s
- String to encode.charEncoding
- String representing the name of
the character encoding of the provided input String.public static String encode(String s, Charset charEncoding)
Does not insert whitespace as described in RFC 1521.
s
- String to encode.charEncoding
- The character encoding of the provided input String.public static char[] encode(byte[] b)
Does not insert whitespace as described in RFC 1521.
Avoids creating extra copies of the input/output.
b
- byte array to encode.public static char[] encode(byte[] b, boolean rfc2045)
Does not insert whitespace as described in RFC 1521, unless rfc2045 is passed as true.
Avoids creating extra copies of the input/output.
b
- byte array to encode.rfc2045
- If true, break lines at 76 characters with CRLFpublic static String decode(String encoded, String charEncoding)
Unlike decode(char[])
, extra whitespace is ignored.
encoded
- String to decode.charEncoding
- String representing the character encoding
used to map the decoded bytes into a String.UnsupportedCharsetException
- if the encoding is not supportedIllegalArgumentException
- if the input is not a valid
B64 encoding.public static String decode(String encoded, Charset charEncoding)
Unlike decode(char[])
, extra whitespace is ignored.
encoded
- String to decode.charEncoding
- Character encoding
used to map the decoded bytes into a String.IllegalArgumentException
- if the input is not a valid
B64 encoding.public static byte[] decode(char[] b)
Unlike other decode methods, this does not attempt to cope with extra whitespace as described in RFC 1521/2045.
Avoids creating extra copies of the input/output.
Note this code has been flattened for performance.
b
- char array to decode.IllegalArgumentException
- if the input is not a valid
B64 encoding.public static byte[] decode(String encoded)
Unlike decode(char[])
, extra whitespace is ignored.
encoded
- String to decode.IllegalArgumentException
- if the input is not a valid
B64 encoding.public static void decode(String encoded, ByteArrayOutputStream bout)
Unlike decode(char[])
, extra whitespace is ignored.
encoded
- String to decode.bout
- stream for decoded bytesIllegalArgumentException
- if the input is not a valid
B64 encoding.public static void encode(int value, Appendable buf) throws IOException
IOException
public static void encode(long lvalue, Appendable buf) throws IOException
IOException
Copyright © 1995-2015 Webtide. All Rights Reserved.