Class StiBase64DecoderUtil

java.lang.Object
com.stimulsoft.lib.base64.StiBase64DecoderUtil

public final class StiBase64DecoderUtil extends Object
Class decodes a Base64 encoded data back into the original byte representation and writes to output stream.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a Base64Decoder waiting on calls to its translate() method.
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    decode(byte[] data)
    Decode given byte array into a decoded byte array.
    static byte[]
    decode(byte[] data, int begin, int end)
    Decode given byte array into a decoded byte array.
    static void
    Decode bytes from input stream and write decoded bytes to output stream.
    static void
    decode(InputStream input, OutputStream out, long count)
    Decode bytes from input stream and write decoded bytes to output stream.
    static byte[]
     
    void
    Writes all decoded octets.
    translate(byte[] bytes)
    Translate every base64 character from given byte array into a sextet byte value by using above translation array.
    translate(byte[] bytes, int begin, int end)
    Translate every base64 character from given byte array into a sextet byte value by using above translation array.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StiBase64DecoderUtil

      public StiBase64DecoderUtil(OutputStream stream)
      Construct a Base64Decoder waiting on calls to its translate() method. Base64Decoder must be flushed to write internally buffered data to output stream.
  • Method Details

    • decode

      public static void decode(InputStream input, OutputStream out) throws IOException
      Decode bytes from input stream and write decoded bytes to output stream.
      Parameters:
      input - input stream
      out - output stream
      Throws:
      IOException - if an I/O error occurs
    • decode

      public static void decode(InputStream input, OutputStream out, long count) throws IOException
      Decode bytes from input stream and write decoded bytes to output stream.
      Parameters:
      input - input stream
      out - output stream
      count - count of bytes to read and decode; -1 for all available bytes
      Throws:
      IOException - if an I/O error occurs
    • decode

      public static byte[] decode(String str)
    • decode

      public static byte[] decode(byte[] data)
      Decode given byte array into a decoded byte array.
      Parameters:
      data - Base64 byte array to be decoded.
      Returns:
      All decoded octets as byte array.
    • decode

      public static byte[] decode(byte[] data, int begin, int end)
      Decode given byte array into a decoded byte array.
      Parameters:
      data - Base64 byte array to be decoded
      begin - index of the first byte to start from
      end - index after the last byte
      Returns:
      All decoded octets as byte array.
    • translate

      public StiBase64DecoderUtil translate(byte[] bytes) throws IOException
      Translate every base64 character from given byte array into a sextet byte value by using above translation array. The sextets are then shifted into an buffer until the buffer contains 4 sextets which are then decoded into 3 octets. The translate and decode process is continued until all bytes of given byte array are evaluated. If there are remaining sextets in the buffer they also will be converted into octets at the end. All the converted octets are written to the output stream.
      Parameters:
      bytes - the byte array to be decoded
      Returns:
      Base64Decoder
      Throws:
      IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
    • translate

      public StiBase64DecoderUtil translate(byte[] bytes, int begin, int end) throws IOException
      Translate every base64 character from given byte array into a sextet byte value by using above translation array. The sextets are then shifted into an buffer until the buffer contains 4 sextets which are then decoded into 3 octets. The translate and decode process is continued until all bytes of given byte array are evaluated. If there are remaining sextets in the buffer they also will be converted into octets at the end. All the converted octets are written to the output stream.
      Parameters:
      bytes - the byte array to be decoded
      begin - index of the first byte to start from
      end - index after the last byte
      Returns:
      Base64Decoder
      Throws:
      IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
    • flush

      public void flush() throws IOException
      Writes all decoded octets.
      Throws:
      IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.