|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.OutputStream org.deegree.commons.utils.io.StreamBufferStore
public class StreamBufferStore
Scalable alternative to ByteArrayOutputStream
that automatically switches to file-based storage if the amount
of written bytes exceeds a given limit.
Field Summary | |
---|---|
static int |
DEFAULT_LIMIT
Default limit (1 MB) |
Constructor Summary | |
---|---|
StreamBufferStore()
Creates a new StreamBufferStore instance that switches to file storage when
DEFAULT_LIMIT bytes have been written. |
|
StreamBufferStore(int limit)
Creates a new StreamBufferStore instance that switches to file storage when the specified number of bytes
have been written. |
|
StreamBufferStore(int limit,
File targetFile)
Creates a new StreamBufferStore instance that switches to file storage when the specified number of bytes
have been written. |
Method Summary | |
---|---|
void |
close()
|
void |
flush()
|
InputStream |
getInputStream()
Returns an InputStream for accessing the previously written bytes. |
void |
reset()
Clears any data that exists in the buffer. |
int |
size()
Returns the current size of the buffer. |
void |
write(byte[] b)
|
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
void |
writeTo(OutputStream outputStream)
Writes the complete contents of this buffer to the specified output stream argument, as if by calling the output stream's write method using out.write(buf, 0, count) . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_LIMIT
Constructor Detail |
---|
public StreamBufferStore()
StreamBufferStore
instance that switches to file storage when
DEFAULT_LIMIT
bytes have been written.
public StreamBufferStore(int limit)
StreamBufferStore
instance that switches to file storage when the specified number of bytes
have been written.
limit
- number of bytes when switching to file will occurpublic StreamBufferStore(int limit, File targetFile)
StreamBufferStore
instance that switches to file storage when the specified number of bytes
have been written.
limit
- number of bytes when switching to file will occurtargetFile
- file to use if written bytes exceed limit, must not be null
Method Detail |
---|
public int size()
public InputStream getInputStream() throws IOException
InputStream
for accessing the previously written bytes.
InputStream
, never null
IOException
public void close() throws IOException
close
in interface Closeable
close
in class OutputStream
IOException
public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
public void write(byte[] b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in class OutputStream
IOException
public void write(int b) throws IOException
write
in class OutputStream
IOException
public void writeTo(OutputStream outputStream) throws IOException
out.write(buf, 0, count)
.
outputStream
- stream to write to, must not be null
IOException
- if an I/O error occurspublic void reset()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |