org.abstracthorizon.mercury.imap.util.section
Class MeasuredInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.abstracthorizon.mercury.imap.util.section.MeasuredInputStream
All Implemented Interfaces:
Closeable

public class MeasuredInputStream
extends InputStream

Input stream that counts number of bytes and let only specified number of bytes to be read

Author:
Daniel Sendula

Field Summary
protected  InputStream is
          Wrapped input stream
protected  long len
          Maximum len
protected  long mark
          Mark
protected  long read
          Amount of read bytes
 
Constructor Summary
MeasuredInputStream(InputStream is, long len)
          Constructor
 
Method Summary
 int available()
           
 void close()
           
 void mark(int readlimit)
           
 boolean markSupported()
           
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
 void reset()
           
 long size()
          Returns measured size
 long skip(long n)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

is

protected InputStream is
Wrapped input stream


len

protected long len
Maximum len


read

protected long read
Amount of read bytes


mark

protected long mark
Mark

Constructor Detail

MeasuredInputStream

public MeasuredInputStream(InputStream is,
                           long len)
Constructor

Parameters:
is - input stream
len - expected len
Method Detail

size

public long size()
Returns measured size

Returns:
measured size

available

public int available()
              throws IOException
Overrides:
available in class InputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException

mark

public void mark(int readlimit)
Overrides:
mark in class InputStream

markSupported

public boolean markSupported()
Overrides:
markSupported in class InputStream

read

public int read()
         throws IOException
Specified by:
read in class InputStream
Throws:
IOException

read

public int read(byte[] b)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

reset

public void reset()
           throws IOException
Overrides:
reset in class InputStream
Throws:
IOException

skip

public long skip(long n)
          throws IOException
Overrides:
skip in class InputStream
Throws:
IOException


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.