Package org.opends.server.loggers
Class MeteredStream
java.lang.Object
java.io.OutputStream
org.opends.server.loggers.MeteredStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
A metered stream is a subclass of OutputStream that (a) forwards all its output to a target stream (b) keeps track of
how many bytes have been written.
-
Constructor Summary
ConstructorsConstructorDescriptionMeteredStream(OutputStream out, long written) Create the stream wrapped around the specified output stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the output stream which closes the target output stream.voidflush()Flush the output stream which flushes the target output stream.longReturns the number of bytes written in this stream.voidwrite(byte[] buff) voidwrite(byte[] buff, int off, int len) voidwrite(int b) Methods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
MeteredStream
Create the stream wrapped around the specified output stream.- Parameters:
out- The target output stream to keep track of.written- The number of bytes written to the stream.
-
-
Method Details
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
flush
Flush the output stream which flushes the target output stream.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException- if the flush failed.
-
close
Close the output stream which closes the target output stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException- if the close failed.
-
getBytesWritten
public long getBytesWritten()Returns the number of bytes written in this stream.- Returns:
- the number of bytes
-