Package org.saidone.misc
Class ProgressTrackingOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.saidone.misc.ProgressTrackingOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
OutputStream
wrapper that logs upload progress for debugging purposes.
Bytes written to the underlying stream are counted and progress is logged in 10% increments when trace logging is enabled.
-
Field Summary
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
ConstructorsConstructorDescriptionProgressTrackingOutputStream
(OutputStream out, String nodeId, long contentLength) Creates a new progress tracking output stream. -
Method Summary
Methods inherited from class java.io.FilterOutputStream
close, flush, write
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
ProgressTrackingOutputStream
Creates a new progress tracking output stream.- Parameters:
out
- the underlying output streamnodeId
- identifier of the node being writtencontentLength
- total expected length of the stream in bytes
-
-
Method Details
-
write
Writes a single byte and updates the write progress.- Overrides:
write
in classFilterOutputStream
- Parameters:
b
- the byte to be written- Throws:
IOException
- if an I/O error occurs
-
write
Writes bytes from a buffer and updates the write progress.- Overrides:
write
in classFilterOutputStream
- Parameters:
b
- the dataoff
- the start offset in the datalen
- the number of bytes to write- Throws:
IOException
- if an I/O error occurs
-