net.sourceforge.groboutils.util.io.v1
Class MimeInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byjava.io.FilterInputStream
          extended bynet.sourceforge.groboutils.util.io.v1.MimeInputStream

public class MimeInputStream
extends java.io.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

Since:
0.9.0 Alpha (early 2000)
Version:
$Date: 2003/02/10 22:52:45 $
Author:
Matt Albrecht groboclown@users.sourceforge.net

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
MimeInputStream(java.io.InputStream i)
          Constructor!
 
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.io.FilterInputStream
close, mark, markSupported, read, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MimeInputStream

public MimeInputStream(java.io.InputStream i)
Constructor!

Method Detail

read

public int read()
         throws java.io.IOException
Write the specified byte, performing mime encoding.

Override this method, since all other write methods call it.

Throws:
java.io.IOException - If an I/O error occurs

skip

public long skip(long n)
          throws java.io.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.

Parameters:
n - the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.
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 from this input stream without blocking.

This method performs in.available(n), does the mime-size conversion, and returns the result.

Returns:
the number of bytes that can be read from the input stream without blocking.
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
FilterInputStream.in


Copyright © 2001-2003 by The GroboUtils Project