at.gv.egovernment.moa.util
Class Base64Utils
java.lang.Object
|
+--at.gv.egovernment.moa.util.Base64Utils
- public class Base64Utils
- extends Object
Utitility functions for encoding/decoding Base64 strings.
- Version:
- $Id$
- Author:
- Patrick Peck
|
Method Summary |
static byte[] |
decode(String base64String,
boolean ignoreInvalidChars)
Read the bytes encoded in a Base64 encoded String. |
static InputStream |
decodeToStream(String base64String,
boolean ignoreInvalidChars)
Read the bytes encoded in a Base64 encoded String and provide
them via an InputStream. |
static String |
encode(byte[] bytes)
Convert a byte array to a Base64 encoded String. |
static String |
encode(InputStream inputStream)
Convert the data contained in the given stream to a Base64 encoded
String. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Base64Utils
public Base64Utils()
decode
public static byte[] decode(String base64String,
boolean ignoreInvalidChars)
throws IOException
- Read the bytes encoded in a Base64 encoded
String.
- Parameters:
base64String - The String containing the Base64 encoded
bytes.ignoreInvalidChars - Whether to ignore invalid Base64 characters.- Returns:
- byte[] The raw bytes contained in the
base64String. - Throws:
IOException - Failed to read the Base64 data.
decodeToStream
public static InputStream decodeToStream(String base64String,
boolean ignoreInvalidChars)
- Read the bytes encoded in a Base64 encoded
String and provide
them via an InputStream.
- Parameters:
base64String - The String containing the Base64 encoded
bytes.ignoreInvalidChars - Whether to ignore invalid Base64 characters.- Returns:
- The
InputStream from which the binary content of the
base64String can be read.
encode
public static String encode(byte[] bytes)
throws IOException
- Convert a byte array to a Base64 encoded
String.
- Parameters:
bytes - The bytes to encode.- Returns:
- String The Base64 encoded representation of the
bytes. - Throws:
IOException - Failed to write the bytes as Base64 data.
encode
public static String encode(InputStream inputStream)
throws IOException
- Convert the data contained in the given stream to a Base64 encoded
String.
- Parameters:
inputStream - The stream containing the data to encode.- Returns:
- The Base64 encoded data of
inputStream, as a
String. - Throws:
IOException - Failed to convert the data in the stream.