Package org.ojalgo.netio
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 aSupplier
, but assumed to be reading from a file or some other source of data, and therefore extendsCloseable
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
FromFileReader.Builder<F>
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
close()
static void
copy(java.io.File sourceFile, java.util.Properties destinationMap)
Read the properties file and copy the entries to the supplied destinationProperties
instance.static void
delete(java.io.File file)
Delete this file or directory (does not need to be empty).static <T extends java.io.Serializable>
TdeserializeObjectFromFile(java.io.File file)
default int
drainTo(java.util.Collection<? super T> container, int maxElements)
Behaves similar toBlockingQueue.drainTo(Collection, int)
except that returning 0 means there are no more items to read.static <T> FromFileReader<T>
empty()
default void
forEachInBacthes(int batchSize, java.util.function.Consumer<? super T> action)
Similar toIterable.forEach(Consumer)
but processes items in batches.static java.io.InputStream
input(java.io.File file)
static java.io.InputStream
input(java.io.File file, OperatorWithException<java.io.InputStream> filter)
default java.util.Iterator<T>
iterator()
default <U> FromFileReader<U>
map(java.util.function.Function<T,U> mapper)
static <F> FromFileReader.Builder<F>
newBuilder(F... file)
static FromFileReader.Builder<java.io.File>
newBuilder(java.io.File file)
static FromFileReader.Builder<java.nio.file.Path>
newBuilder(java.nio.file.Path file)
static FromFileReader.Builder<SegmentedFile.Segment>
newBuilder(SegmentedFile segmented)
static FromFileReader.Builder<java.io.File>
newBuilder(ShardedFile sharded)
T
read()
Returning null indicates that there are no more items to read.default java.util.stream.Stream<T>
stream()
-
-
-
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 destinationProperties
instance.- Parameters:
sourceFile
- Source properties filedestinationMap
- 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)
-
empty
static <T> FromFileReader<T> empty()
-
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)
-
newBuilder
static <F> FromFileReader.Builder<F> newBuilder(F... file)
-
newBuilder
static FromFileReader.Builder<java.io.File> newBuilder(java.io.File file)
-
newBuilder
static FromFileReader.Builder<java.nio.file.Path> newBuilder(java.nio.file.Path file)
-
newBuilder
static FromFileReader.Builder<SegmentedFile.Segment> newBuilder(SegmentedFile segmented)
-
newBuilder
static FromFileReader.Builder<java.io.File> newBuilder(ShardedFile sharded)
-
close
default void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
drainTo
default int drainTo(java.util.Collection<? super T> container, int maxElements)
Behaves similar toBlockingQueue.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 toIterable.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 interfacejava.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 asBufferedReader.readLine()
. All implementations must return null precisely once.
-
stream
default java.util.stream.Stream<T> stream()
-
-