Package at.gv.egovernment.moaspss.util
Class Base64Utils
java.lang.Object
at.gv.egovernment.moaspss.util.Base64Utils
Utitility functions for encoding/decoding Base64 strings.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]static byte[]Read the bytes encoded in a Base64 encodedString.static InputStreamdecodeToStream(String base64String, boolean ignoreInvalidChars) static InputStreamdecodeToStream(String base64String, boolean ignoreInvalidChars, String encoding) Read the bytes encoded in a Base64 encodedStringand provide them via anInputStream.static Stringencode(byte[] bytes) Convert a byte array to a Base64 encodedString.static Stringstatic Stringencode(InputStream inputStream) static Stringencode(InputStream inputStream, String encoding) Convert the data contained in the given stream to a Base64 encodedString.
-
Constructor Details
-
Base64Utils
public Base64Utils()
-
-
Method Details
-
decode
public static byte[] decode(String base64String, boolean ignoreInvalidChars, String encoding) throws IOException Read the bytes encoded in a Base64 encodedString.- Parameters:
base64String- TheStringcontaining the Base64 encoded bytes.ignoreInvalidChars- Whether to ignore invalid Base64 characters.encoding- Char encoding that should be used- Returns:
- byte[] The raw bytes contained in the
base64String. - Throws:
IOException- Failed to read the Base64 data.
-
decode
- Throws:
IOException
-
decodeToStream
public static InputStream decodeToStream(String base64String, boolean ignoreInvalidChars, String encoding) Read the bytes encoded in a Base64 encodedStringand provide them via anInputStream.- Parameters:
base64String- TheStringcontaining the Base64 encoded bytes.ignoreInvalidChars- Whether to ignore invalid Base64 characters.- Returns:
- The
InputStreamfrom which the binary content of thebase64Stringcan be read.
-
decodeToStream
-
encode
Convert a byte array to a Base64 encodedString.- 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
- Throws:
IOException
-
encode
- Throws:
IOException
-
encode
Convert the data contained in the given stream to a Base64 encodedString.- Parameters:
inputStream- The stream containing the data to encode.- Returns:
- The Base64 encoded data of
inputStream, as aString. - Throws:
IOException- Failed to convert the data in the stream.
-