org.ztemplates.actions.util
Class ZBase64Util.InputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by org.ztemplates.actions.util.ZBase64Util.InputStream
All Implemented Interfaces:
Closeable
Enclosing class:
ZBase64Util

public static class ZBase64Util.InputStream
extends FilterInputStream

A ZBase64Util.InputStream will read data from another java.io.InputStream, given in the constructor, and encode/decode to/from Base64 notation on the fly.

Since:
1.3
See Also:
ZBase64Util

Constructor Summary
ZBase64Util.InputStream(InputStream in)
          Constructs a ZBase64Util.InputStream in DECODE mode.
ZBase64Util.InputStream(InputStream in, int options)
          Constructs a ZBase64Util.InputStream in either ENCODE or DECODE mode.
 
Method Summary
 int read()
          Reads enough of the input stream to convert to/from Base64 and returns the next byte.
 int read(byte[] dest, int off, int len)
          Calls read() repeatedly until the end of stream is reached or len bytes are read.
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZBase64Util.InputStream

public ZBase64Util.InputStream(InputStream in)
Constructs a ZBase64Util.InputStream in DECODE mode.

Parameters:
in - the java.io.InputStream from which to read data.
Since:
1.3

ZBase64Util.InputStream

public ZBase64Util.InputStream(InputStream in,
                               int options)
Constructs a ZBase64Util.InputStream in either ENCODE or DECODE mode.

Valid options:

                                   ENCODE or DECODE: Encode or Decode as data is read.
                                   DONT_BREAK_LINES: don't break lines at 76 characters
                                     (only meaningful when encoding)
                                     <i>Note: Technically, this makes your encoding non-compliant.</i>
 

Example: new Base64.InputStream( in, Base64.DECODE )

Parameters:
in - the java.io.InputStream from which to read data.
options - Specified options
Since:
2.0
See Also:
ZBase64Util.ENCODE, ZBase64Util.DECODE, ZBase64Util.DONT_BREAK_LINES
Method Detail

read

public int read()
         throws IOException
Reads enough of the input stream to convert to/from Base64 and returns the next byte.

Overrides:
read in class FilterInputStream
Returns:
next byte
Throws:
IOException
Since:
1.3

read

public int read(byte[] dest,
                int off,
                int len)
         throws IOException
Calls read() repeatedly until the end of stream is reached or len bytes are read. Returns number of bytes read into array or -1 if end of stream is encountered.

Overrides:
read in class FilterInputStream
Parameters:
dest - array to hold values
off - offset for array
len - max number of bytes to read into array
Returns:
bytes read into array or -1 if end of stream is encountered.
Throws:
IOException
Since:
1.3


Copyright © 2011. All Rights Reserved.