Class Base64InputStream

java.lang.Object
java.io.InputStream
org.simpleframework.common.encode.Base64InputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class Base64InputStream extends InputStream
The Base64InputStream is used to read base64 text in the form of a string through a conventional input stream. This is provided for convenience so that it is possible to encode and decode binary data as base64 for implementations that would normally use a binary format.
See Also:
  • Field Details

    • encoded

      private char[] encoded
      This is that original base64 text that is to be decoded.
    • decoded

      private byte[] decoded
      This is used to accumulate the decoded text as an array.
    • temp

      private byte[] temp
      This is a temporary buffer used to read one byte at a time.
    • count

      private int count
      This is the total number of bytes that have been read.
  • Constructor Details

    • Base64InputStream

      public Base64InputStream(String source)
      Constructor for the Base64InputStream object. This takes an encoded string and reads it as binary data.
      Parameters:
      source - this string containing the encoded data
  • Method Details

    • read

      public int read() throws IOException
      This is used to read the next byte decoded from the text. If the data has been fully consumed then this will return the standard -1.
      Specified by:
      read in class InputStream
      Returns:
      this returns the next octet decoded
      Throws:
      IOException
    • read

      public int read(byte[] array, int offset, int length) throws IOException
      This is used to read the next byte decoded from the text. If the data has been fully consumed then this will return the standard -1.
      Overrides:
      read in class InputStream
      Parameters:
      array - this is the array to decode the text to
      offset - this is the offset to decode in to the array
      this - is the number of bytes available to decode to
      Returns:
      this returns the number of octets decoded
      Throws:
      IOException
    • toString

      public String toString()
      This returns the original base64 text that was encoded. This is useful for debugging purposes to see the source data.
      Overrides:
      toString in class Object
      Returns:
      this returns the original base64 text to decode