Package org.apache.commons.io.input
Class TimestampedObserver
- java.lang.Object
-
- org.apache.commons.io.input.ObservableInputStream.Observer
-
- org.apache.commons.io.input.TimestampedObserver
-
public class TimestampedObserver extends ObservableInputStream.Observer
An observer with timestamps.For example:
final TimestampedObserver timetampedObserver = new TimestampedObserver(); try (final ObservableInputStream inputStream = new ObservableInputStream(...), timetampedObserver)) { ... } System.out.printf("IO duration: %s%n", timetampedObserver.getOpenToCloseDuration());- Since:
- 2.9.0
-
-
Constructor Summary
Constructors Constructor Description TimestampedObserver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclosed()Called to indicate that theObservableInputStreamhas been closed.java.time.InstantgetCloseInstant()Gets the instant for when this instance was closed.java.time.InstantgetOpenInstant()Gets the instant for when this instance was created.java.time.DurationgetOpenToCloseDuration()Gets the Duration between creation and close.java.time.DurationgetOpenToNowDuration()Gets the Duration between creation and now.java.lang.StringtoString()-
Methods inherited from class org.apache.commons.io.input.ObservableInputStream.Observer
data, data, error, finished
-
-
-
-
Method Detail
-
closed
public void closed() throws java.io.IOExceptionDescription copied from class:ObservableInputStream.ObserverCalled to indicate that theObservableInputStreamhas been closed.- Overrides:
closedin classObservableInputStream.Observer- Throws:
java.io.IOException- if an I/O error occurs.
-
getCloseInstant
public java.time.Instant getCloseInstant()
Gets the instant for when this instance was closed.- Returns:
- the instant for when closed was called.
-
getOpenToCloseDuration
public java.time.Duration getOpenToCloseDuration()
Gets the Duration between creation and close.- Returns:
- the Duration between creation and close.
-
getOpenToNowDuration
public java.time.Duration getOpenToNowDuration()
Gets the Duration between creation and now.- Returns:
- the Duration between creation and now.
-
getOpenInstant
public java.time.Instant getOpenInstant()
Gets the instant for when this instance was created.- Returns:
- the instant for when this instance was created.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-