|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object it.sauronsoftware.base64.Base64
public class Base64
Base64 encoding and decoding utility methods, both for binary and textual informations.
Constructor Summary | |
---|---|
Base64()
|
Method Summary | |
---|---|
static byte[] |
decode(byte[] bytes)
Decodes a binary sequence. |
static void |
decode(java.io.File source,
java.io.File target)
Decodes data from the given source file contents and writes them in the given target file. |
static void |
decode(java.io.InputStream inputStream,
java.io.OutputStream outputStream)
Decodes data from the given input stream and writes them in the given output stream. |
static java.lang.String |
decode(java.lang.String str)
Decodes the supplied string. |
static java.lang.String |
decode(java.lang.String str,
java.lang.String charset)
Decodes the supplied string. |
static byte[] |
encode(byte[] bytes)
Encodes a binary sequence. |
static byte[] |
encode(byte[] bytes,
int wrapAt)
Encodes a binary sequence, wrapping every encoded line every wrapAt characters. |
static void |
encode(java.io.File source,
java.io.File target)
Encodes data from the given source file contents and writes them in the given target file. |
static void |
encode(java.io.File source,
java.io.File target,
int wrapAt)
Encodes data from the given source file contents and writes them in the given target file, wrapping every encoded line every wrapAt characters. |
static void |
encode(java.io.InputStream inputStream,
java.io.OutputStream outputStream)
Encodes data from the given input stream and writes them in the given output stream. |
static void |
encode(java.io.InputStream inputStream,
java.io.OutputStream outputStream,
int wrapAt)
Encodes data from the given input stream and writes them in the given output stream, wrapping every encoded line every wrapAt characters. |
static java.lang.String |
encode(java.lang.String str)
Encodes a string. |
static java.lang.String |
encode(java.lang.String str,
java.lang.String charset)
Encodes a string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Base64()
Method Detail |
---|
public static java.lang.String encode(java.lang.String str) throws java.lang.RuntimeException
Encodes a string.
Before the string is encoded in Base64, it is converted in a binary sequence using the system default charset.
str
- The source string.
java.lang.RuntimeException
- If an unexpected error occurs.public static java.lang.String encode(java.lang.String str, java.lang.String charset) throws java.lang.RuntimeException
Encodes a string.
Before the string is encoded in Base64, it is converted in a binary sequence using the supplied charset.
str
- The source stringcharset
- The charset name.
java.lang.RuntimeException
- If an unexpected error occurs.public static java.lang.String decode(java.lang.String str) throws java.lang.RuntimeException
Decodes the supplied string.
The supplied string is decoded into a binary sequence, and then the sequence is encoded with the system default charset and returned.
str
- The encoded string.
java.lang.RuntimeException
- If an unexpected error occurs.public static java.lang.String decode(java.lang.String str, java.lang.String charset) throws java.lang.RuntimeException
Decodes the supplied string.
The supplied string is decoded into a binary sequence, and then the sequence is encoded with the supplied charset and returned.
str
- The encoded string.charset
- The charset name.
java.lang.RuntimeException
- If an unexpected error occurs.public static byte[] encode(byte[] bytes) throws java.lang.RuntimeException
Encodes a binary sequence.
If data are large, i.e. if you are working with large binary files,
consider to use a Base64OutputStream
instead of loading too much
data in memory.
bytes
- The source sequence.
java.lang.RuntimeException
- If an unexpected error occurs.public static byte[] encode(byte[] bytes, int wrapAt) throws java.lang.RuntimeException
Encodes a binary sequence, wrapping every encoded line every wrapAt characters. A wrapAt value less than 1 disables wrapping.
If data are large, i.e. if you are working with large binary files,
consider to use a Base64OutputStream
instead of loading too much
data in memory.
bytes
- The source sequence.wrapAt
- The max line length for encoded data. If less than 1 no wrap
is applied.
java.lang.RuntimeException
- If an unexpected error occurs.public static byte[] decode(byte[] bytes) throws java.lang.RuntimeException
Decodes a binary sequence.
If data are large, i.e. if you are working with large binary files,
consider to use a Base64InputStream
instead of loading too much
data in memory.
bytes
- The encoded sequence.
java.lang.RuntimeException
- If an unexpected error occurs.public static void encode(java.io.InputStream inputStream, java.io.OutputStream outputStream) throws java.io.IOException
Encodes data from the given input stream and writes them in the given output stream.
The supplied input stream is read until its end is reached, but it's not closed by this method.
The supplied output stream is nor flushed neither closed by this method.
inputStream
- The input stream.outputStream
- The output stream.
java.io.IOException
- If an I/O error occurs.public static void encode(java.io.InputStream inputStream, java.io.OutputStream outputStream, int wrapAt) throws java.io.IOException
Encodes data from the given input stream and writes them in the given output stream, wrapping every encoded line every wrapAt characters. A wrapAt value less than 1 disables wrapping.
The supplied input stream is read until its end is reached, but it's not closed by this method.
The supplied output stream is nor flushed neither closed by this method.
inputStream
- The input stream from which clear data are read.outputStream
- The output stream in which encoded data are written.wrapAt
- The max line length for encoded data. If less than 1 no wrap
is applied.
java.io.IOException
- If an I/O error occurs.public static void decode(java.io.InputStream inputStream, java.io.OutputStream outputStream) throws java.io.IOException
Decodes data from the given input stream and writes them in the given output stream.
The supplied input stream is read until its end is reached, but it's not closed by this method.
The supplied output stream is nor flushed neither closed by this method.
inputStream
- The input stream from which encoded data are read.outputStream
- The output stream in which decoded data are written.
java.io.IOException
- If an I/O error occurs.public static void encode(java.io.File source, java.io.File target, int wrapAt) throws java.io.IOException
Encodes data from the given source file contents and writes them in the given target file, wrapping every encoded line every wrapAt characters. A wrapAt value less than 1 disables wrapping.
source
- The source file, from which decoded data are read.target
- The target file, in which encoded data are written.wrapAt
- The max line length for encoded data. If less than 1 no wrap
is applied.
java.io.IOException
- If an I/O error occurs.public static void encode(java.io.File source, java.io.File target) throws java.io.IOException
Encodes data from the given source file contents and writes them in the given target file.
source
- The source file, from which decoded data are read.target
- The target file, in which encoded data are written.
java.io.IOException
- If an I/O error occurs.public static void decode(java.io.File source, java.io.File target) throws java.io.IOException
Decodes data from the given source file contents and writes them in the given target file.
source
- The source file, from which encoded data are read.target
- The target file, in which decoded data are written.
java.io.IOException
- If an I/O error occurs.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |