|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.OutputStream java.io.FilterOutputStream ccs.utils.DammedOutputStream
public class DammedOutputStream
An output stream filter which only permits a fixed amount of data to be
written to the underlying stream. Data written after this "dam" has been
reached throws an IOException; so does closing prematurely. This rather
strange stream is required by BeeTree, but could conceivably be useful
elsewhere. Note that this is not the exact mirror-image of
DammedInputStream
.
Field Summary |
---|
Fields inherited from class java.io.FilterOutputStream |
---|
out |
Constructor Summary | |
---|---|
DammedOutputStream(java.io.OutputStream out,
long quota)
Creates a dammed output stream. |
Method Summary | |
---|---|
void |
close()
Closes the stream if the quota has been fulfilled. |
void |
finish()
Asserts that the write on the stream should be complete, and throws IOException if it isn't. |
void |
setDam(long quota)
Sets the dam to a new quota, relative to the current position |
void |
write(byte[] b,
int off,
int len)
Writes len bytes from b
starting at off to
this output stream. |
void |
write(int b)
Writes the specified byte to this output stream. |
Methods inherited from class java.io.FilterOutputStream |
---|
flush, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DammedOutputStream(java.io.OutputStream out, long quota)
out
- The underlying output stream.quota
- The number of bytes that may be written to out, or -1
to disable the dam. (Use setDam to activate it).Method Detail |
---|
public void write(int b) throws java.io.IOException
write
in class java.io.FilterOutputStream
b
- the byte.
java.io.IOException
- if an I/O error occurs.public void write(byte[] b, int off, int len) throws java.io.IOException
len
bytes from b
starting at off
to
this output stream. No bytes are written if doing so would exceed the quota.
write
in class java.io.FilterOutputStream
b
- the data.off
- the start offset in the data.len
- the number of bytes to write.
java.io.IOException
- if an I/O error occurs.public void finish() throws java.io.IOException
java.io.IOException
- if the the quota has not been fulfilled.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.FilterOutputStream
java.io.IOException
- if the the quota has not been fulfilled.public void setDam(long quota)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |