com.bradmcevoy.io
Class BufferingOutputStream
java.lang.Object
java.io.OutputStream
com.bradmcevoy.io.BufferingOutputStream
- All Implemented Interfaces:
- java.io.Closeable, java.io.Flushable
public class BufferingOutputStream
- extends java.io.OutputStream
An output stream which will buffer data, initially using memory up to
maxMemorySize, and then overflowing to a temporary file.
To use this class you will write to it, and then close it, and then
call getInputStream to read the data.
The temporary file, if it was created, will be deleted when the inputstream
is closed.
- Author:
- brad
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BufferingOutputStream
public BufferingOutputStream(int maxMemorySize)
getInputStream
public java.io.InputStream getInputStream()
write
public void write(byte[] b)
throws java.io.IOException
- Overrides:
write in class java.io.OutputStream
- Throws:
java.io.IOException
write
public void write(int b)
throws java.io.IOException
- Specified by:
write in class java.io.OutputStream
- Throws:
java.io.IOException
write
public void write(byte[] b,
int off,
int len)
throws java.io.IOException
- Overrides:
write in class java.io.OutputStream
- Throws:
java.io.IOException
flush
public void flush()
throws java.io.IOException
- Specified by:
flush in interface java.io.Flushable- Overrides:
flush in class java.io.OutputStream
- Throws:
java.io.IOException
close
public void close()
throws java.io.IOException
- Specified by:
close in interface java.io.Closeable- Overrides:
close in class java.io.OutputStream
- Throws:
java.io.IOException
getSize
public long getSize()
setOnClose
public void setOnClose(java.lang.Runnable r)
isCompleteInMemory
public boolean isCompleteInMemory()
- returns true if the data is completely held in memory
- Returns:
getInMemoryData
public byte[] getInMemoryData()
- Gets the data currently held in memory
- Returns:
finalize
protected void finalize()
throws java.lang.Throwable
- Overrides:
finalize in class java.lang.Object
- Throws:
java.lang.Throwable
deleteTempFileIfExists
public void deleteTempFileIfExists()
Copyright © 2011. All Rights Reserved.