Class Base64DecodeStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class Base64DecodeStream
    extends java.io.InputStream
    This class implements a Base64 Character decoder as specified in RFC1113. Unlike some other encoding schemes there is nothing in this encoding that tells the decoder where a buffer starts or stops, so to use it you will need to isolate your encoded data into a single chunk and then feed them this decoder. The simplest way to do that is to read all of the encoded data into a string and then use:
          byte    data[];
          InputStream is = new ByteArrayInputStream(data);
          is = new Base64DecodeStream(is);
     
    On errors, this class throws a IOException with the following detail strings:
        "Base64DecodeStream: Bad Padding byte (2)."
        "Base64DecodeStream: Bad Padding byte (1)."
     
    Version:
    $Id$ Originally authored by Thomas DeWeese, Vincent Hardy, and Chuck McManis.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) byte[] decodeBuffer  
      (package private) boolean eof  
      (package private) byte[] outBuffer  
      (package private) int outOffset  
      private static byte[] PEM_ARRAY  
      (package private) java.io.InputStream src  
    • Constructor Summary

      Constructors 
      Constructor Description
      Base64DecodeStream​(java.io.InputStream src)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()  
      void close()  
      (package private) boolean getNextAtom()  
      boolean markSupported()  
      int read()  
      int read​(byte[] out, int offset, int len)  
      • Methods inherited from class java.io.InputStream

        mark, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • src

        java.io.InputStream src
      • PEM_ARRAY

        private static final byte[] PEM_ARRAY
      • decodeBuffer

        byte[] decodeBuffer
      • outBuffer

        byte[] outBuffer
      • outOffset

        int outOffset
      • eof

        boolean eof
    • Constructor Detail

      • Base64DecodeStream

        public Base64DecodeStream​(java.io.InputStream src)
    • Method Detail

      • markSupported

        public boolean markSupported()
        Overrides:
        markSupported in class java.io.InputStream
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.InputStream
        Throws:
        java.io.IOException
      • available

        public int available()
                      throws java.io.IOException
        Overrides:
        available in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

        public int read()
                 throws java.io.IOException
        Specified by:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] out,
                        int offset,
                        int len)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • getNextAtom

        final boolean getNextAtom()
                           throws java.io.IOException
        Throws:
        java.io.IOException