Package org.apache.commons.io.function
Interface IOStream<T>
- Type Parameters:
T- the type of the stream elements.
- All Superinterfaces:
AutoCloseable,Closeable,IOBaseStream<T,IOStream<T>, Stream<T>>
Like
Stream but throws IOException.- Since:
- 2.12.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> IOStream<T> Constructs a new IOStream for the given Stream.default booleanallMatch(IOPredicate<? super T> predicate) LikeStream.allMatch(java.util.function.Predicate)but throwsIOException.default booleananyMatch(IOPredicate<? super T> predicate) LikeStream.anyMatch(java.util.function.Predicate)but throwsIOException.default <R,A> R TODO Package-private for now, needs IOCollector?default <R> Rcollect(IOSupplier<R> supplier, IOBiConsumer<R, ? super T> accumulator, IOBiConsumer<R, R> combiner) default longcount()LikeStream.count().distinct()LikeStream.distinct().static <T> IOStream<T> empty()This class' version ofStream.empty().filter(IOPredicate<? super T> predicate) findAny()LikeStream.findAny().LikeStream.findFirst().default <R> IOStream<R> flatMap(IOFunction<? super T, ? extends IOStream<? extends R>> mapper) default DoubleStreamflatMapToDouble(IOFunction<? super T, ? extends DoubleStream> mapper) TODO Package-private for now, needs IODoubleStream?default IntStreamflatMapToInt(IOFunction<? super T, ? extends IntStream> mapper) TODO Package-private for now, needs IOIntStream?default LongStreamflatMapToLong(IOFunction<? super T, ? extends LongStream> mapper) TODO Package-private for now, needs IOLongStream?default voidforAll(IOConsumer<T> action) Performs an action for each element gathering any exceptions.default voidforAll(IOConsumer<T> action, BiFunction<Integer, IOException, IOException> exSupplier) Performs an action for each element gathering any exceptions.default voidforEach(IOConsumer<? super T> action) LikeStream.forEach(java.util.function.Consumer)but throwsIOException.default voidforEachOrdered(IOConsumer<? super T> action) static <T> IOStream<T> iterate(T seed, IOUnaryOperator<T> f) LikeStream.iterate(Object, UnaryOperator)but for IO.limit(long maxSize) LikeStream.limit(long).default <R> IOStream<R> map(IOFunction<? super T, ? extends R> mapper) default DoubleStreammapToDouble(ToDoubleFunction<? super T> mapper) TODO Package-private for now, needs IOToDoubleFunction?default IntStreammapToInt(ToIntFunction<? super T> mapper) TODO Package-private for now, needs IOToIntFunction?default LongStreammapToLong(ToLongFunction<? super T> mapper) TODO Package-private for now, needs IOToLongFunction?max(IOComparator<? super T> comparator) min(IOComparator<? super T> comparator) default booleannoneMatch(IOPredicate<? super T> predicate) static <T> IOStream<T> Null-safe version ofStreamSupport.stream(java.util.Spliterator, boolean).static <T> IOStream<T> of(T t) Returns a sequentialIOStreamImplcontaining a single element.static <T> IOStream<T> of(T... values) Null-safe version ofStream.of(Object[])for an IO stream.peek(IOConsumer<? super T> action) reduce(IOBinaryOperator<T> accumulator) default Treduce(T identity, IOBinaryOperator<T> accumulator) default <U> Ureduce(U identity, IOBiFunction<U, ? super T, U> accumulator, IOBinaryOperator<U> combiner) skip(long n) LikeStream.skip(long).sorted()LikeStream.sorted().sorted(IOComparator<? super T> comparator) default Object[]toArray()LikeStream.toArray().default <A> A[]toArray(IntFunction<A[]> generator) TODO Package-private for now, needs IOIntFunction?Methods inherited from interface org.apache.commons.io.function.IOBaseStream
asBaseStream, close, isParallel, iterator, onClose, parallel, sequential, spliterator, unordered, unwrap, wrap
-
Method Details
-
adapt
Constructs a new IOStream for the given Stream.- Type Parameters:
T- the type of the stream elements.- Parameters:
stream- The stream to delegate.- Returns:
- a new IOStream.
-
empty
This class' version ofStream.empty().- Type Parameters:
T- the type of the stream elements- Returns:
- an empty sequential
IOStreamImpl. - See Also:
-
iterate
LikeStream.iterate(Object, UnaryOperator)but for IO.- Type Parameters:
T- the type of stream elements.- Parameters:
seed- the initial element.f- a function to be applied to the previous element to produce a new element.- Returns:
- a new sequential
IOStream.
-
of
Null-safe version ofStreamSupport.stream(java.util.Spliterator, boolean). Copied from Apache Commons Lang.- Type Parameters:
T- the type of stream elements.- Parameters:
values- the elements of the new stream, may benull.- Returns:
- the new stream on
valuesorStream.empty().
-
of
Null-safe version ofStream.of(Object[])for an IO stream.- Type Parameters:
T- the type of stream elements.- Parameters:
values- the elements of the new stream, may benull.- Returns:
- the new stream on
valuesorStream.empty().
-
of
Returns a sequentialIOStreamImplcontaining a single element.- Type Parameters:
T- the type of stream elements- Parameters:
t- the single element- Returns:
- a singleton sequential stream
-
allMatch
LikeStream.allMatch(java.util.function.Predicate)but throwsIOException.- Parameters:
predicate-Stream.allMatch(java.util.function.Predicate).- Returns:
- Like
Stream.allMatch(java.util.function.Predicate). - Throws:
IOException- if an I/O error occurs.
-
anyMatch
LikeStream.anyMatch(java.util.function.Predicate)but throwsIOException.- Parameters:
predicate-Stream.anyMatch(java.util.function.Predicate).- Returns:
- Like
Stream.anyMatch(java.util.function.Predicate). - Throws:
IOException- if an I/O error occurs.
-
collect
TODO Package-private for now, needs IOCollector? Adding this method now and an IO version later is an issue because call sites would have to type-cast to pick one. It would be ideal to have only one. LikeStream.collect(Collector). Package private for now.- Type Parameters:
R- LikeStream.collect(Collector).A- LikeStream.collect(Collector).- Parameters:
collector- LikeStream.collect(Collector).- Returns:
- Like
Stream.collect(Collector).
-
collect
default <R> R collect(IOSupplier<R> supplier, IOBiConsumer<R, ? super T> accumulator, IOBiConsumer<R, throws IOExceptionR> combiner) - Type Parameters:
R- LikeStream.collect(java.util.function.Supplier, java.util.function.BiConsumer, java.util.function.BiConsumer).- Parameters:
supplier- LikeStream.collect(java.util.function.Supplier, java.util.function.BiConsumer, java.util.function.BiConsumer).accumulator- LikeStream.collect(java.util.function.Supplier, java.util.function.BiConsumer, java.util.function.BiConsumer).combiner- LikeStream.collect(java.util.function.Supplier, java.util.function.BiConsumer, java.util.function.BiConsumer).- Returns:
- Like
Stream.collect(java.util.function.Supplier, java.util.function.BiConsumer, java.util.function.BiConsumer). - Throws:
IOException- if an I/O error occurs.
-
count
LikeStream.count().- Returns:
- Like
Stream.count().
-
distinct
LikeStream.distinct().- Returns:
- Like
Stream.distinct().
-
filter
- Parameters:
predicate- LikeStream.filter(java.util.function.Predicate).- Returns:
- Like
Stream.filter(java.util.function.Predicate). - Throws:
IOException- if an I/O error occurs.
-
findAny
LikeStream.findAny().- Returns:
- Like
Stream.findAny().
-
findFirst
LikeStream.findFirst().- Returns:
- Like
Stream.findFirst().
-
flatMap
default <R> IOStream<R> flatMap(IOFunction<? super T, ? extends IOStream<? extends R>> mapper) throws IOException- Type Parameters:
R- LikeStream.flatMap(java.util.function.Function).- Parameters:
mapper- LikeStream.flatMap(java.util.function.Function).- Returns:
- Like
Stream.flatMap(java.util.function.Function). - Throws:
IOException- if an I/O error occurs.
-
flatMapToDouble
default DoubleStream flatMapToDouble(IOFunction<? super T, ? extends DoubleStream> mapper) throws IOExceptionTODO Package-private for now, needs IODoubleStream? Adding this method now and an IO version later is an issue because call sites would have to type-cast to pick one. It would be ideal to have only one. LikeStream.flatMapToDouble(java.util.function.Function).- Parameters:
mapper- LikeStream.flatMapToDouble(java.util.function.Function).- Returns:
- Like
Stream.flatMapToDouble(java.util.function.Function). - Throws:
IOException- if an I/O error occurs.
-
flatMapToInt
TODO Package-private for now, needs IOIntStream? Adding this method now and an IO version later is an issue because call sites would have to type-cast to pick one. It would be ideal to have only one. LikeStream.flatMapToInt(java.util.function.Function).- Parameters:
mapper- LikeStream.flatMapToInt(java.util.function.Function).- Returns:
- Like
Stream.flatMapToInt(java.util.function.Function). - Throws:
IOException- if an I/O error occurs.
-
flatMapToLong
default LongStream flatMapToLong(IOFunction<? super T, ? extends LongStream> mapper) throws IOExceptionTODO Package-private for now, needs IOLongStream? Adding this method now and an IO version later is an issue because call sites would have to type-cast to pick one. It would be ideal to have only one. LikeStream.flatMapToLong(java.util.function.Function).- Parameters:
mapper- LikeStream.flatMapToLong(java.util.function.Function).- Returns:
- Like
Stream.flatMapToLong(java.util.function.Function). - Throws:
IOException- if an I/O error occurs.
-
forAll
Performs an action for each element gathering any exceptions.- Parameters:
action- The action to apply to each element.- Throws:
IOExceptionList- if any I/O errors occur.
-
forAll
default void forAll(IOConsumer<T> action, BiFunction<Integer, IOException, throws IOExceptionListIOException> exSupplier) Performs an action for each element gathering any exceptions.- Parameters:
action- The action to apply to each element.exSupplier- The exception supplier.- Throws:
IOExceptionList- if any I/O errors occur.
-
forEach
LikeStream.forEach(java.util.function.Consumer)but throwsIOException.- Parameters:
action- LikeStream.forEach(java.util.function.Consumer).- Throws:
IOException- if an I/O error occurs.
-
forEachOrdered
- Parameters:
action- LikeStream.forEachOrdered(java.util.function.Consumer).- Throws:
IOException- if an I/O error occurs.
-
limit
LikeStream.limit(long).- Parameters:
maxSize- LikeStream.limit(long).- Returns:
- Like
Stream.limit(long).
-
map
- Type Parameters:
R- LikeStream.map(java.util.function.Function).- Parameters:
mapper- LikeStream.map(java.util.function.Function).- Returns:
- Like
Stream.map(java.util.function.Function). - Throws:
IOException- if an I/O error occurs.
-
mapToDouble
TODO Package-private for now, needs IOToDoubleFunction? Adding this method now and an IO version later is an issue because call sites would have to type-cast to pick one. It would be ideal to have only one. LikeStream.mapToDouble(ToDoubleFunction). Package private for now.- Parameters:
mapper- LikeStream.mapToDouble(ToDoubleFunction).- Returns:
- Like
Stream.mapToDouble(ToDoubleFunction).
-
mapToInt
TODO Package-private for now, needs IOToIntFunction? Adding this method now and an IO version later is an issue because call sites would have to type-cast to pick one. It would be ideal to have only one. LikeStream.mapToInt(ToIntFunction). Package private for now.- Parameters:
mapper- LikeStream.mapToInt(ToIntFunction).- Returns:
- Like
Stream.mapToInt(ToIntFunction).
-
mapToLong
TODO Package-private for now, needs IOToLongFunction? Adding this method now and an IO version later is an issue because call sites would have to type-cast to pick one. It would be ideal to have only one. LikeStream.mapToLong(ToLongFunction). Package private for now.- Parameters:
mapper- LikeStream.mapToLong(ToLongFunction).- Returns:
- Like
Stream.mapToLong(ToLongFunction).
-
max
- Parameters:
comparator- LikeStream.max(java.util.Comparator).- Returns:
- Like
Stream.max(java.util.Comparator). - Throws:
IOException- if an I/O error occurs.
-
min
- Parameters:
comparator- LikeStream.min(java.util.Comparator).- Returns:
- Like
Stream.min(java.util.Comparator). - Throws:
IOException- if an I/O error occurs.
-
noneMatch
- Parameters:
predicate- LikeStream.noneMatch(java.util.function.Predicate).- Returns:
- Like
Stream.noneMatch(java.util.function.Predicate). - Throws:
IOException- if an I/O error occurs.
-
peek
- Parameters:
action- LikeStream.peek(java.util.function.Consumer).- Returns:
- Like
Stream.peek(java.util.function.Consumer). - Throws:
IOException- if an I/O error occurs.
-
reduce
- Parameters:
accumulator- LikeStream.reduce(java.util.function.BinaryOperator).- Returns:
- Like
Stream.reduce(java.util.function.BinaryOperator). - Throws:
IOException- if an I/O error occurs.
-
reduce
- Parameters:
identity- LikeStream.reduce(Object, java.util.function.BinaryOperator).accumulator- LikeStream.reduce(Object, java.util.function.BinaryOperator).- Returns:
- Like
Stream.reduce(Object, java.util.function.BinaryOperator). - Throws:
IOException- if an I/O error occurs.
-
reduce
default <U> U reduce(U identity, IOBiFunction<U, ? super T, throws IOExceptionU> accumulator, IOBinaryOperator<U> combiner) - Type Parameters:
U- LikeStream.reduce(Object, BiFunction, java.util.function.BinaryOperator).- Parameters:
identity- LikeStream.reduce(Object, BiFunction, java.util.function.BinaryOperator).accumulator- LikeStream.reduce(Object, BiFunction, java.util.function.BinaryOperator).combiner- LikeStream.reduce(Object, BiFunction, java.util.function.BinaryOperator).- Returns:
- Like
Stream.reduce(Object, BiFunction, java.util.function.BinaryOperator). - Throws:
IOException- if an I/O error occurs.
-
skip
LikeStream.skip(long).- Parameters:
n- LikeStream.skip(long).- Returns:
- Like
Stream.skip(long).
-
sorted
LikeStream.sorted().- Returns:
- Like
Stream.sorted().
-
sorted
- Parameters:
comparator- LikeStream.sorted(java.util.Comparator).- Returns:
- Like
Stream.sorted(java.util.Comparator). - Throws:
IOException- if an I/O error occurs.
-
toArray
LikeStream.toArray().- Returns:
Stream.toArray().
-
toArray
TODO Package-private for now, needs IOIntFunction? Adding this method now and an IO version later is an issue because call sites would have to type-cast to pick one. It would be ideal to have only one. LikeStream.toArray(IntFunction). Package private for now.- Type Parameters:
A- LikeStream.toArray(IntFunction).- Parameters:
generator- LikeStream.toArray(IntFunction).- Returns:
- Like
Stream.toArray(IntFunction).
-