org.yajul.io
Class Base64InputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by org.yajul.io.AbstractByteFilterInputStream
              extended by org.yajul.io.Base64InputStream
All Implemented Interfaces:
java.io.Closeable

public class Base64InputStream
extends AbstractByteFilterInputStream

Provides decoding of BASE64 encoded data as an input stream filter. The underlying input stream is expected to be encoded in BASE64 form.

Author:
Joshua Davis

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
Base64InputStream(java.io.InputStream in)
          Creates a new Base64 decoding input stream, using the input stream (encoded stream).
 
Method Summary
static int parseCharacter(int ch)
          Checks a character for correct BASE64 encoding.
 int read()
          Reads the next byte of data from this input stream.
 
Methods inherited from class org.yajul.io.AbstractByteFilterInputStream
insert, read, readByte
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Base64InputStream

public Base64InputStream(java.io.InputStream in)
Creates a new Base64 decoding input stream, using the input stream (encoded stream).

Parameters:
in - The base 64 encoded input stream
Method Detail

read

public int read()
         throws java.io.IOException
Reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

This method simply performs in.read() and returns the result.

Specified by:
read in class AbstractByteFilterInputStream
Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
FilterInputStream.in

parseCharacter

public static int parseCharacter(int ch)
Checks a character for correct BASE64 encoding. Returns -1 if the character is not valid. Returns END_OF_INPUT if 'ch' is the end of input character.

Parameters:
ch - the input character
Returns:
int The binary value of the input character, or -1 if it is not a valid BASE64 character.


Copyright © 2008. All Rights Reserved.