Package google.registry.util
Class ImprovedOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- google.registry.util.ImprovedOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
- Direct Known Subclasses:
RydePgpSigningOutputStream
@NotThreadSafe public class ImprovedOutputStream extends java.io.FilterOutputStream
OutputStream
wrapper that offers some additional magic.- See Also:
ImprovedInputStream
,CountingOutputStream
-
-
Constructor Summary
Constructors Constructor Description ImprovedOutputStream(java.lang.String name, java.io.OutputStream out)
ImprovedOutputStream(java.lang.String name, java.io.OutputStream out, boolean shouldClose)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Flushes, logs byte count, checks byte count (optional), closes (optional), and self-sabotages.long
getBytesWritten()
Returns the number of bytes that have been written to this stream thus far.protected void
onClose()
Overridable method that's called byclose()
.void
write(byte[] b)
void
write(byte[] b, int off, int len)
void
write(int b)
-
-
-
Method Detail
-
getBytesWritten
public long getBytesWritten()
Returns the number of bytes that have been written to this stream thus far.
-
write
@OverridingMethodsMustInvokeSuper public void write(int b) throws java.io.IOException
- Overrides:
write
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
- See Also:
FilterOutputStream.write(int)
-
write
public final void write(byte[] b) throws java.io.IOException
- Overrides:
write
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
- See Also:
write(byte[], int, int)
-
write
@OverridingMethodsMustInvokeSuper public void write(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
write
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
- See Also:
FilterOutputStream.write(byte[], int, int)
-
close
@NonFinalForTesting public void close() throws java.io.IOException
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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
- See Also:
OutputStream.close()
-
onClose
protected void onClose() throws java.io.IOException
Overridable method that's called byclose()
.This method does nothing by default.
- Throws:
java.io.IOException
-
-