Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


com.tangosol.io
Class Base64InputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.tangosol.io.Base64InputStream

All Implemented Interfaces:
InputStreaming, java.io.Closeable

public class Base64InputStream
extends java.io.InputStream
implements InputStreaming

Reads binary data from a Reader using IETF RFC 2045 Base64 Content Transfer Encoding. Static helpers are available for decoding directly from a char array to a byte array.

Author:
cp 2000.09.07

Field Summary
protected static byte[] EMPTY
          Empty binary data.
protected  int[] m_abGroup
          Group of bytes (stored as ints 0..255).
protected  boolean m_fClosed
          True after close is invoked.
protected  boolean m_fEOF
          True after eof is determined.
protected  int m_ofbGroup
          The offset in the group of bytes.
protected  java.io.Reader m_reader
          The Reader object from which the Base64 encoded data is read.

 

Constructor Summary
Base64InputStream(java.io.Reader reader)
          Construct a Base64InputStream on a Reader object.

 

Method Summary
 int available()
          Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.
 void close()
          Close the stream, flushing any accumulated bytes.
static int decode(char ch)
          Decode one base64 alphabet character.
static byte[] decode(char[] ach)
          Decode the passed character data that was encoded using Base64 encoding.
static byte[] decode(char[] ach, boolean fJunk)
          Decode the passed character data that was encoded using Base64 encoding.
static byte[] decode(char[] ach, int of, int cch)
          Decode the passed character data that was encoded using Base64 encoding.
static byte[] decode(char[] ach, int of, int cch, boolean fJunk)
          Decode the passed character data that was encoded using Base64 encoding.
 int read()
          Reads the next byte of data from the input stream.

 

Methods inherited from class java.io.InputStream
mark, markSupported, read, read, reset, skip

 

Methods inherited from interface com.tangosol.io.InputStreaming
mark, markSupported, read, read, reset, skip

 

Field Detail

EMPTY

protected static final byte[] EMPTY
Empty binary data.

m_fClosed

protected boolean m_fClosed
True after close is invoked.

m_fEOF

protected boolean m_fEOF
True after eof is determined.

m_reader

protected java.io.Reader m_reader
The Reader object from which the Base64 encoded data is read.

m_abGroup

protected int[] m_abGroup
Group of bytes (stored as ints 0..255).

m_ofbGroup

protected int m_ofbGroup
The offset in the group of bytes.

Constructor Detail

Base64InputStream

public Base64InputStream(java.io.Reader reader)
Construct a Base64InputStream on a Reader object.
Parameters:
reader - the Reader to read the Base64 encoded data from

Method Detail

read

public int read()
         throws java.io.IOException
Reads the next byte of data from the 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.
Specified by:
read in interface InputStreaming
Specified by:
read in class java.io.InputStream
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.

available

public int available()
              throws java.io.IOException
Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream. The next caller might be the same thread or or another thread.
Specified by:
available in interface InputStreaming
Overrides:
available in class java.io.InputStream
Returns:
the number of bytes that can be read from this input stream without blocking.
Throws:
java.io.IOException - if an I/O error occurs.

close

public void close()
           throws java.io.IOException
Close the stream, flushing any accumulated bytes. The underlying reader is not closed.
Specified by:
close in interface InputStreaming
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException - if an I/O error occurs.

decode

public static byte[] decode(char[] ach)
Decode the passed character data that was encoded using Base64 encoding.
Parameters:
ach - the array containing the characters to decode
Returns:
the decoded binary data as a byte array

decode

public static byte[] decode(char[] ach,
                            boolean fJunk)
Decode the passed character data that was encoded using Base64 encoding.
Parameters:
ach - the array containing the characters to decode
fJunk - true if the char array may contain whitespace or linefeeds
Returns:
the decoded binary data as a byte array

decode

public static byte[] decode(char[] ach,
                            int of,
                            int cch)
Decode the passed character data that was encoded using Base64 encoding.
Parameters:
ach - the array containing the characters to decode
of - the start offset in the char array
cch - the number of characters to decode
Returns:
the decoded binary data as a byte array

decode

public static byte[] decode(char[] ach,
                            int of,
                            int cch,
                            boolean fJunk)
Decode the passed character data that was encoded using Base64 encoding.
Parameters:
ach - the array containing the characters to decode
of - the start offset in the char array
cch - the number of characters to decode
fJunk - true if the char array may contain whitespace or linefeeds
Returns:
the decoded binary data as a byte array

decode

public static int decode(char ch)
Decode one base64 alphabet character.
Parameters:
ch - the character
Returns:
the ordinal value of the character

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.