org.apache.jackrabbit.mk.util
Class ChunkedOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by org.apache.jackrabbit.mk.util.ChunkedOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class ChunkedOutputStream
extends FilterOutputStream

Output stream that encodes and writes HTTP chunks.


Field Summary
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
ChunkedOutputStream(OutputStream out)
          Create a new instance of this class.
ChunkedOutputStream(OutputStream out, int size)
          Create a new instance of this class.
 
Method Summary
 void close()
          Close this output stream.
 void flush()
          Flush the contents of the internal buffer to the underlying output stream as a chunk if it is non-zero.
 void recycle(OutputStream out)
          Recycle this output stream.
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.io.FilterOutputStream
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChunkedOutputStream

public ChunkedOutputStream(OutputStream out,
                           int size)
Create a new instance of this class.

Parameters:
out - underlying output stream.
size - internal buffer size
Throws:
IllegalArgumentException - if size is smaller than 1 or bigger than 65535

ChunkedOutputStream

public ChunkedOutputStream(OutputStream out)
Create a new instance of this class.

Parameters:
out - underlying output stream.
Method Detail

write

public void write(int b)
           throws IOException
Overrides:
write in class FilterOutputStream
Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Overrides:
write in class FilterOutputStream
Throws:
IOException

flush

public void flush()
           throws IOException
Flush the contents of the internal buffer to the underlying output stream as a chunk if it is non-zero. Never do that for a zero-size chunk as this would indicate EOF.

Specified by:
flush in interface Flushable
Overrides:
flush in class FilterOutputStream
Throws:
IOException
See Also:
FilterOutputStream.flush()

recycle

public void recycle(OutputStream out)
Recycle this output stream.

Parameters:
out - new underlying output stream

close

public void close()
           throws IOException
Close this output stream. Flush the contents of the internal buffer and writes the last chunk to the underlying output stream. Sets the internal reference to the underlying output stream to null. Does not close the underlying output stream.

Specified by:
close in interface Closeable
Overrides:
close in class FilterOutputStream
Throws:
IOException
See Also:
FilterOutputStream.close()


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.