Package google.registry.util
Class ImprovedOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
google.registry.util.ImprovedOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
- Direct Known Subclasses:
RydePgpSigningOutputStream
OutputStream
wrapper that offers some additional magic.
- Byte counting
- Always
FilterOutputStream.flush()
onclose()
- Check expected byte count when closed (Optional)
- Close original
OutputStream
when closed (Optional) - Overridable
onClose()
method - Throws
NullPointerException
if written afterclose()
- See Also:
-
Field Summary
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
ConstructorDescriptionImprovedOutputStream
(String name, OutputStream out) ImprovedOutputStream
(String name, OutputStream out, boolean shouldClose) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Flushes, logs byte count, checks byte count (optional), closes (optional), and self-sabotages.long
Returns the number of bytes that have been written to this stream thus far.protected void
onClose()
Overridable method that's called byclose()
.final void
write
(byte[] b) void
write
(byte[] b, int off, int len) void
write
(int b) Methods inherited from class java.io.FilterOutputStream
flush
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
ImprovedOutputStream
-
ImprovedOutputStream
-
-
Method Details
-
getBytesWritten
public long getBytesWritten()Returns the number of bytes that have been written to this stream thus far. -
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
- See Also:
-
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
- See Also:
-
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
- See Also:
-
close
Flushes, logs byte count, checks byte count (optional), closes (optional), and self-sabotages.This method may not be overridden, use
onClose()
instead.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterOutputStream
- Throws:
IOException
- See Also:
-
onClose
Overridable method that's called byclose()
.This method does nothing by default.
- Throws:
IOException
-