org.apache.commons.httpclient
Class ContentLengthInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--java.io.FilterInputStream
              |
              +--org.apache.commons.httpclient.ContentLengthInputStream

public class ContentLengthInputStream
extends java.io.FilterInputStream

Cuts the wrapped InputStream off after a specified number of bytes.

Since:
2.0
Author:
Ortwin Glück

Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
ContentLengthInputStream(java.io.InputStream in, int contentLength)
          Creates a new length limited stream
 
Method Summary
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentLengthInputStream

public ContentLengthInputStream(java.io.InputStream in,
                                int contentLength)
Creates a new length limited stream
Parameters:
in - The stream to wrap
contentLength - The maximum number of bytes that can be read from the stream. Subsequent read operations will return -1.
Method Detail

read

public int read()
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream

read

public int read(byte[] b)
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream


Copyright (c) 2001 - Apache Software Foundation