Class Base64Utils

java.lang.Object
at.gv.egovernment.moaspss.util.Base64Utils

public class Base64Utils extends Object
Utitility functions for encoding/decoding Base64 strings.
  • 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 encoded String.
      Parameters:
      base64String - The String containing 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

      public static byte[] decode(String base64String, boolean ignoreInvalidChars) throws IOException
      Throws:
      IOException
    • decodeToStream

      public static InputStream decodeToStream(String base64String, boolean ignoreInvalidChars, String encoding)
      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.
    • decodeToStream

      public static InputStream decodeToStream(String base64String, boolean ignoreInvalidChars)
    • 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(byte[] bytes, String encoding) throws IOException
      Throws:
      IOException
    • encode

      public static String encode(InputStream inputStream) throws IOException
      Throws:
      IOException
    • encode

      public static String encode(InputStream inputStream, String encoding) 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.