FileDocCategorySizeDatePackage
ProxyInputStream.javaAPI DocAndroid 1.5 API4342Wed May 06 22:42:46 BST 2009org.apache.commons.io.input

ProxyInputStream

public abstract class ProxyInputStream extends FilterInputStream
A Proxy stream which acts as expected, that is it passes the method calls on to the proxied stream and doesn't change which methods are being called.

It is an alternative base class to FilterInputStream to increase reusability, because FilterInputStream changes the methods being called, such as read(byte[]) to read(byte[], int, int).

author
Stephen Colebourne
version
$Id: ProxyInputStream.java 610010 2008-01-08 14:50:59Z niallp $

Fields Summary
Constructors Summary
public ProxyInputStream(InputStream proxy)
Constructs a new ProxyInputStream.

param
proxy the InputStream to delegate to

        super(proxy);
        // the proxy is stored in a protected superclass variable named 'in'
    
Methods Summary
public intavailable()
Invokes the delegate's available() method.

return
the number of available bytes
throws
IOException if an I/O error occurs

        return in.available();
    
public voidclose()
Invokes the delegate's close() method.

throws
IOException if an I/O error occurs

        in.close();
    
public synchronized voidmark(int idx)
Invokes the delegate's mark(int) method.

param
idx read ahead limit

        in.mark(idx);
    
public booleanmarkSupported()
Invokes the delegate's markSupported() method.

return
true if mark is supported, otherwise false

        return in.markSupported();
    
public intread()
Invokes the delegate's read() method.

return
the byte read or -1 if the end of stream
throws
IOException if an I/O error occurs

        return in.read();
    
public intread(byte[] bts)
Invokes the delegate's read(byte[]) method.

param
bts the buffer to read the bytes into
return
the number of bytes read or -1 if the end of stream
throws
IOException if an I/O error occurs

        return in.read(bts);
    
public intread(byte[] bts, int st, int end)
Invokes the delegate's read(byte[], int, int) method.

param
bts the buffer to read the bytes into
param
st The start offset
param
end The number of bytes to read
return
the number of bytes read or -1 if the end of stream
throws
IOException if an I/O error occurs

        return in.read(bts, st, end);
    
public synchronized voidreset()
Invokes the delegate's reset() method.

throws
IOException if an I/O error occurs

        in.reset();
    
public longskip(long ln)
Invokes the delegate's skip(long) method.

param
ln the number of bytes to skip
return
the number of bytes to skipped or -1 if the end of stream
throws
IOException if an I/O error occurs

        return in.skip(ln);