Package com.helger.commons.io.stream
Class LoggingOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- com.helger.commons.io.stream.WrappedOutputStream
-
- com.helger.commons.io.stream.LoggingOutputStream
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
public class LoggingOutputStream extends WrappedOutputStream
A wrapper around anOutputStreamthat logs what he is doing.- Author:
- Philip Helger
-
-
Field Summary
-
Fields inherited from class java.io.FilterOutputStream
out
-
-
Constructor Summary
Constructors Constructor Description LoggingOutputStream(OutputStream aSourceOS)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()longgetBytesWritten()protected voidonClose(long nTotalBytesWritten)protected voidonWrite(int nBytesWritten, long nTotalBytesWritten)StringtoString()voidwrite(byte[] aBuf, int nOfs, int nLen)voidwrite(int b)-
Methods inherited from class com.helger.commons.io.stream.WrappedOutputStream
getWrappedOutputStream
-
Methods inherited from class java.io.FilterOutputStream
flush, write
-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
-
-
-
Constructor Detail
-
LoggingOutputStream
public LoggingOutputStream(@Nonnull OutputStream aSourceOS)
- Parameters:
aSourceOS- The output stream that should be logged. May not benull.
-
-
Method Detail
-
getBytesWritten
@Nonnegative public final long getBytesWritten()
- Returns:
- The number of written bytes. Always ≥ 0.
-
onWrite
@OverrideOnDemand protected void onWrite(@Nonnegative int nBytesWritten, long nTotalBytesWritten)
-
onClose
@OverrideOnDemand protected void onClose(long nTotalBytesWritten)
-
write
public final void write(int b) throws IOException- Overrides:
writein classFilterOutputStream- Throws:
IOException
-
write
public final void write(@Nonnull byte[] aBuf, int nOfs, int nLen) throws IOException
- Overrides:
writein classWrappedOutputStream- Throws:
IOException
-
close
public final void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterOutputStream- Throws:
IOException
-
toString
public String toString()
- Overrides:
toStringin classWrappedOutputStream
-
-