net.groboclown.util.io.v1
Class MimeInputStream
java.lang.Object
|
+--java.io.InputStream
|
+--java.io.FilterInputStream
|
+--net.groboclown.util.io.v1.MimeInputStream
- public class MimeInputStream
- extends FilterInputStream
java.io.FilterInputStream implementation for Mime base 64. Not incredibly
efficient, but it works and is small.
All we need to implement are:
read(int)
read( byte b[], int off, int len )
skip( long n ) - for translating the # of bytes to skip into mime bytes (4-to-3 ratio)
available() - for the same reason as skip
Method Summary |
int |
available()
Returns the number of bytes that can be read from this input
stream without blocking. |
int |
read()
Write the specified byte , performing mime encoding. |
long |
skip(long n)
Skips over and discards n bytes of data from the
input stream. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
bits
private int bits
spare
private int spare
charset
private static final int[] charset
- Mime character set translation
UPPER_START
private static final int UPPER_START
LOWER_START
private static final int LOWER_START
NUM_START
private static final int NUM_START
PLUS
private static final int PLUS
SLASH
private static final int SLASH
pad
private static final int pad
MimeInputStream
public MimeInputStream(InputStream i)
- Constructor!
read
public int read()
throws IOException
- Write the specified
byte
, performing mime encoding.
Override this method, since all other write methods call it.
- Overrides:
read
in class FilterInputStream
- Throws:
IOException
- If an I/O error occurs
skip
public long skip(long n)
throws IOException
- Skips over and discards
n
bytes of data from the
input stream. The skip
method may, for a variety of
reasons, end up skipping over some smaller number of bytes,
possibly 0
. The actual number of bytes skipped is
returned.
This method performs in.skip(n)
, followed by a quick
translation to mime size.
- Overrides:
skip
in class FilterInputStream
- Parameters:
n
- the number of bytes to be skipped.- Returns:
- the actual number of bytes skipped.
- Throws:
IOException
- if an I/O error occurs.
available
public int available()
throws IOException
- Returns the number of bytes that can be read from this input
stream without blocking.
This method performs in.available(n)
, does the mime-size
conversion, and returns the result.
- Overrides:
available
in class FilterInputStream
- Returns:
- the number of bytes that can be read from the input stream
without blocking.
- Throws:
IOException
- if an I/O error occurs.- See Also:
FilterInputStream.in
Written under the LGPL