Interface FromFileReader<T>

  • All Superinterfaces:
    java.lang.AutoCloseable, java.io.Closeable, java.lang.Iterable<T>
    All Known Implementing Classes:
    DataReader, ManagedReader, MappedReader, QueuedReader, SequencedReader, TextLineReader
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface FromFileReader<T>
    extends java.lang.Iterable<T>, java.io.Closeable
    Essentially just a Supplier, but assumed to be reading from a file or some other source of data, and therefore extends Closeable.
    • Method Detail

      • copy

        static void copy​(java.io.File sourceFile,
                         java.util.Properties destinationMap)
        Read the properties file and copy the entries to the supplied destination Properties instance.
        Parameters:
        sourceFile - Source properties file
        destinationMap - Destination properties map
      • delete

        static void delete​(java.io.File file)
        Delete this file or directory (does not need to be empty).
        Parameters:
        file - Path to a file or directory to be deleted
      • deserializeObjectFromFile

        static <T extends java.io.Serializable> T deserializeObjectFromFile​(java.io.File file)
      • input

        static java.io.InputStream input​(java.io.File file)
      • input

        static java.io.InputStream input​(java.io.File file,
                                         OperatorWithException<java.io.InputStream> filter)
      • close

        default void close()
                    throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • drainTo

        default int drainTo​(java.util.Collection<? super T> container,
                            int maxElements)
        Behaves similar to BlockingQueue.drainTo(Collection, int) except that returning 0 means there are no more items to read.
      • forEachInBacthes

        default void forEachInBacthes​(int batchSize,
                                      java.util.function.Consumer<? super T> action)
        Similar to Iterable.forEach(Consumer) but processes items in batches. Will extract up to batchSize items before calling the action, and then repeat until no more items are available.
      • iterator

        default java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<T>
      • map

        default <U> FromFileReader<U> map​(java.util.function.Function<T,​U> mapper)
      • read

        T read()
        Returning null indicates that there are no more items to read. That's the same behaviour as BufferedReader.readLine(). All implementations must return null precisely once.
      • stream

        default java.util.stream.Stream<T> stream()