Package org.apache.commons.io.input
Class TimestampedObserver
java.lang.Object
org.apache.commons.io.input.ObservableInputStream.Observer
org.apache.commons.io.input.TimestampedObserver
An observer with timestamps.
For example:
final TimestampedObserver timestampedObserver = new TimestampedObserver(); try (ObservableInputStream inputStream = new ObservableInputStream(...), timestampedObserver)) { ... } System.out.printf("IO duration: %s%n", timestampedObserver.getOpenToCloseDuration());
- Since:
- 2.9.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
closed()
Called to indicate that theObservableInputStream
has been closed.Gets the instant for when this instance was closed.Gets the instant for when this instance was created.Gets the Duration between creation and close.Gets the Duration between creation and now.boolean
isClosed()
Tests whetherclosed()
has been called.toString()
Methods inherited from class org.apache.commons.io.input.ObservableInputStream.Observer
data, data, error, finished
-
Constructor Details
-
TimestampedObserver
public TimestampedObserver()Constructs a new instance.
-
-
Method Details
-
closed
Description copied from class:ObservableInputStream.Observer
Called to indicate that theObservableInputStream
has been closed.- Overrides:
closed
in classObservableInputStream.Observer
- Throws:
IOException
- if an I/O error occurs.
-
getCloseInstant
Gets the instant for when this instance was closed.- Returns:
- the instant for when closed was called.
-
getOpenInstant
Gets the instant for when this instance was created.- Returns:
- the instant for when this instance was created.
-
getOpenToCloseDuration
Gets the Duration between creation and close.- Returns:
- the Duration between creation and close.
-
getOpenToNowDuration
Gets the Duration between creation and now.- Returns:
- the Duration between creation and now.
-
isClosed
Tests whetherclosed()
has been called.- Returns:
- whether
closed()
has been called. - Since:
- 2.12.0
-
toString
-