org.apache.chemistry.opencmis.server.shared
Class ThresholdOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.apache.chemistry.opencmis.server.shared.ThresholdOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class ThresholdOutputStream
extends OutputStream

An OutputStream that stores the data in main memory until it reaches a threshold. If the threshold is passed the data is written to a temporary file. It it is important to close this OutputStream before getInputStream() is called or call destroy() if the InputStream isn't required!


Nested Class Summary
static interface ThresholdOutputStream.ThresholdInputStream
          Provides information about the input stream.
 
Constructor Summary
ThresholdOutputStream(File tempDir, int memoryThreshold)
           
ThresholdOutputStream(int initSize, File tempDir, int memoryThreshold)
           
 
Method Summary
 void close()
           
 void destroy()
          Destroys the object before it has been read.
 void flush()
           
 InputStream getInputStream()
          Returns the data as an InputStream.
 long getSize()
           
 void write(byte[] buffer)
           
 void write(byte[] buffer, int offset, int len)
           
 void write(int oneByte)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThresholdOutputStream

public ThresholdOutputStream(File tempDir,
                             int memoryThreshold)

ThresholdOutputStream

public ThresholdOutputStream(int initSize,
                             File tempDir,
                             int memoryThreshold)
Method Detail

getSize

public long getSize()

write

public void write(byte[] buffer)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(byte[] buffer,
                  int offset,
                  int len)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(int oneByte)
           throws IOException
Specified by:
write in class OutputStream
Throws:
IOException

flush

public void flush()
           throws IOException
Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException

destroy

public void destroy()
Destroys the object before it has been read.


getInputStream

public InputStream getInputStream()
                           throws Exception
Returns the data as an InputStream.

Throws:
Exception


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