org.apache.http.impl.io
Class ContentLengthOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byorg.apache.http.impl.io.ContentLengthOutputStream

public class ContentLengthOutputStream
extends java.io.OutputStream

A stream wrapper that closes itself after a defined number of bytes.

Since:
4.0
Version:
$Revision: 503192 $
Author:
Oleg Kalnichevski

Constructor Summary
ContentLengthOutputStream(HttpDataTransmitter out, long contentLength)
          Creates a new length limited stream
 
Method Summary
 void close()
          Does not close the underlying socket output.
 void flush()
           
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentLengthOutputStream

public ContentLengthOutputStream(HttpDataTransmitter out,
                                 long contentLength)
Creates a new length limited stream

Parameters:
out - The data transmitter to wrap
contentLength - The maximum number of bytes that can be written to the stream. Subsequent write operations will be ignored.
Since:
4.0
Method Detail

close

public void close()
           throws java.io.IOException

Does not close the underlying socket output.

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

flush

public void flush()
           throws java.io.IOException
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Throws:
java.io.IOException

write

public void write(byte[] b)
           throws java.io.IOException
Throws:
java.io.IOException

write

public void write(int b)
           throws java.io.IOException
Throws:
java.io.IOException


Copyright © 2005-2007 Apache Software Foundation. All Rights Reserved.