info.informatica.io
Class LimitedReader

java.lang.Object
  extended by java.io.Reader
      extended by java.io.FilterReader
          extended by info.informatica.io.LimitedReader
All Implemented Interfaces:
Closeable, Readable

public class LimitedReader
extends FilterReader

A Reader with resource limit.

This class allows to have control over the amount of bytes flowing through the Reader.

Version:
1.01
Author:
amengual at informatica dot info

Constructor Summary
LimitedReader(Reader re)
          Creates a LimitedReader with the default limit of 4 MB.
LimitedReader(Reader re, int maxsize)
          Creates a LimitedReader with the specified max size.
 
Method Summary
 int getBytesTransferred()
           
 int read()
           
 int read(char[] cbuf)
           
 int read(char[] cbuf, int off, int len)
           
 String readAll()
           
 String readAll(int filelen)
           
 
Methods inherited from class java.io.FilterReader
close, mark, markSupported, ready, reset, skip
 
Methods inherited from class java.io.Reader
read
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LimitedReader

public LimitedReader(Reader re,
                     int maxsize)
Creates a LimitedReader with the specified max size.

Parameters:
re - the Reader.
maxsize - the max amount of bytes that this stream is allowed to read.

LimitedReader

public LimitedReader(Reader re)
Creates a LimitedReader with the default limit of 4 MB.

Parameters:
re - the Reader.
Method Detail

readAll

public String readAll()
               throws IOException
Throws:
IOException

readAll

public String readAll(int filelen)
               throws IOException
Throws:
IOException

getBytesTransferred

public int getBytesTransferred()

read

public int read()
         throws IOException
Overrides:
read in class FilterReader
Throws:
IOException

read

public int read(char[] cbuf)
         throws IOException
Overrides:
read in class Reader
Throws:
IOException

read

public int read(char[] cbuf,
                int off,
                int len)
         throws IOException
Overrides:
read in class FilterReader
Throws:
IOException