org.apache.commons.io.input

Class 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 Detail

      • TimestampedObserver

        public TimestampedObserver()
    • Method Detail

      • getCloseInstant

        public Instant getCloseInstant()
        Gets the instant for when this instance was closed.
        Returns:
        the instant for when closed was called.
      • getOpenToCloseDuration

        public Duration getOpenToCloseDuration()
        Gets the Duration between creation and close.
        Returns:
        the Duration between creation and close.
      • getOpenToNowDuration

        public Duration getOpenToNowDuration()
        Gets the Duration between creation and now.
        Returns:
        the Duration between creation and now.
      • getOpenInstant

        public Instant getOpenInstant()
        Gets the instant for when this instance was created.
        Returns:
        the instant for when this instance was created.

Copyright © 2002–2021 The Apache Software Foundation. All rights reserved.