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 SummaryModifier 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.IOBaseStreamasBaseStream, close, isParallel, iterator, onClose, parallel, sequential, spliterator, unordered, unwrap, wrap
- 
Method Details- 
adaptConstructs 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.
 
- 
emptyThis class' version ofStream.empty().- Type Parameters:
- T- the type of the stream elements
- Returns:
- an empty sequential IOStreamImpl.
- See Also:
 
- 
iterateLikeStream.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.
 
- 
ofNull-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 be- null.
- Returns:
- the new stream on valuesorStream.empty().
 
- 
ofNull-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 be- null.
- Returns:
- the new stream on valuesorStream.empty().
 
- 
ofReturns a sequentialIOStreamImplcontaining a single element.- Type Parameters:
- T- the type of stream elements
- Parameters:
- t- the single element
- Returns:
- a singleton sequential stream
 
- 
allMatchLikeStream.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.
 
- 
anyMatchLikeStream.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.
 
- 
collectTODO 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- Like- Stream.collect(Collector).
- A- Like- Stream.collect(Collector).
- Parameters:
- collector- Like- Stream.collect(Collector).
- Returns:
- Like Stream.collect(Collector).
 
- 
collectdefault <R> R collect(IOSupplier<R> supplier, IOBiConsumer<R, ? super T> accumulator, IOBiConsumer<R, throws IOExceptionR> combiner) - Type Parameters:
- R- Like- Stream.collect(java.util.function.Supplier, java.util.function.BiConsumer, java.util.function.BiConsumer).
- Parameters:
- supplier- Like- Stream.collect(java.util.function.Supplier, java.util.function.BiConsumer, java.util.function.BiConsumer).
- accumulator- Like- Stream.collect(java.util.function.Supplier, java.util.function.BiConsumer, java.util.function.BiConsumer).
- combiner- Like- Stream.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.
 
- 
countLikeStream.count().- Returns:
- Like Stream.count().
 
- 
distinctLikeStream.distinct().- Returns:
- Like Stream.distinct().
 
- 
filter- Parameters:
- predicate- Like- Stream.filter(java.util.function.Predicate).
- Returns:
- Like Stream.filter(java.util.function.Predicate).
- Throws:
- IOException- if an I/O error occurs.
 
- 
findAnyLikeStream.findAny().- Returns:
- Like Stream.findAny().
 
- 
findFirstLikeStream.findFirst().- Returns:
- Like Stream.findFirst().
 
- 
flatMapdefault <R> IOStream<R> flatMap(IOFunction<? super T, ? extends IOStream<? extends R>> mapper) throws IOException- Type Parameters:
- R- Like- Stream.flatMap(java.util.function.Function).
- Parameters:
- mapper- Like- Stream.flatMap(java.util.function.Function).
- Returns:
- Like Stream.flatMap(java.util.function.Function).
- Throws:
- IOException- if an I/O error occurs.
 
- 
flatMapToDoubledefault 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- Like- Stream.flatMapToDouble(java.util.function.Function).
- Returns:
- Like Stream.flatMapToDouble(java.util.function.Function).
- Throws:
- IOException- if an I/O error occurs.
 
- 
flatMapToIntTODO 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- Like- Stream.flatMapToInt(java.util.function.Function).
- Returns:
- Like Stream.flatMapToInt(java.util.function.Function).
- Throws:
- IOException- if an I/O error occurs.
 
- 
flatMapToLongdefault 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- Like- Stream.flatMapToLong(java.util.function.Function).
- Returns:
- Like Stream.flatMapToLong(java.util.function.Function).
- Throws:
- IOException- if an I/O error occurs.
 
- 
forAllPerforms 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.
 
- 
forAlldefault 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.
 
- 
forEachLikeStream.forEach(java.util.function.Consumer)but throwsIOException.- Parameters:
- action- Like- Stream.forEach(java.util.function.Consumer).
- Throws:
- IOException- if an I/O error occurs.
 
- 
forEachOrdered- Parameters:
- action- Like- Stream.forEachOrdered(java.util.function.Consumer).
- Throws:
- IOException- if an I/O error occurs.
 
- 
limitLikeStream.limit(long).- Parameters:
- maxSize- Like- Stream.limit(long).
- Returns:
- Like Stream.limit(long).
 
- 
map- Type Parameters:
- R- Like- Stream.map(java.util.function.Function).
- Parameters:
- mapper- Like- Stream.map(java.util.function.Function).
- Returns:
- Like Stream.map(java.util.function.Function).
- Throws:
- IOException- if an I/O error occurs.
 
- 
mapToDoubleTODO 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- Like- Stream.mapToDouble(ToDoubleFunction).
- Returns:
- Like Stream.mapToDouble(ToDoubleFunction).
 
- 
mapToIntTODO 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- Like- Stream.mapToInt(ToIntFunction).
- Returns:
- Like Stream.mapToInt(ToIntFunction).
 
- 
mapToLongTODO 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- Like- Stream.mapToLong(ToLongFunction).
- Returns:
- Like Stream.mapToLong(ToLongFunction).
 
- 
max- Parameters:
- comparator- Like- Stream.max(java.util.Comparator).
- Returns:
- Like Stream.max(java.util.Comparator).
- Throws:
- IOException- if an I/O error occurs.
 
- 
min- Parameters:
- comparator- Like- Stream.min(java.util.Comparator).
- Returns:
- Like Stream.min(java.util.Comparator).
- Throws:
- IOException- if an I/O error occurs.
 
- 
noneMatch- Parameters:
- predicate- Like- Stream.noneMatch(java.util.function.Predicate).
- Returns:
- Like Stream.noneMatch(java.util.function.Predicate).
- Throws:
- IOException- if an I/O error occurs.
 
- 
peek- Parameters:
- action- Like- Stream.peek(java.util.function.Consumer).
- Returns:
- Like Stream.peek(java.util.function.Consumer).
- Throws:
- IOException- if an I/O error occurs.
 
- 
reduce- Parameters:
- accumulator- Like- Stream.reduce(java.util.function.BinaryOperator).
- Returns:
- Like Stream.reduce(java.util.function.BinaryOperator).
- Throws:
- IOException- if an I/O error occurs.
 
- 
reduce- Parameters:
- identity- Like- Stream.reduce(Object, java.util.function.BinaryOperator).
- accumulator- Like- Stream.reduce(Object, java.util.function.BinaryOperator).
- Returns:
- Like Stream.reduce(Object, java.util.function.BinaryOperator).
- Throws:
- IOException- if an I/O error occurs.
 
- 
reducedefault <U> U reduce(U identity, IOBiFunction<U, ? super T, throws IOExceptionU> accumulator, IOBinaryOperator<U> combiner) - Type Parameters:
- U- Like- Stream.reduce(Object, BiFunction, java.util.function.BinaryOperator).
- Parameters:
- identity- Like- Stream.reduce(Object, BiFunction, java.util.function.BinaryOperator).
- accumulator- Like- Stream.reduce(Object, BiFunction, java.util.function.BinaryOperator).
- combiner- Like- Stream.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.
 
- 
skipLikeStream.skip(long).- Parameters:
- n- Like- Stream.skip(long).
- Returns:
- Like Stream.skip(long).
 
- 
sortedLikeStream.sorted().- Returns:
- Like Stream.sorted().
 
- 
sorted- Parameters:
- comparator- Like- Stream.sorted(java.util.Comparator).
- Returns:
- Like Stream.sorted(java.util.Comparator).
- Throws:
- IOException- if an I/O error occurs.
 
- 
toArrayLikeStream.toArray().- Returns:
- Stream.toArray().
 
- 
toArrayTODO 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- Like- Stream.toArray(IntFunction).
- Parameters:
- generator- Like- Stream.toArray(IntFunction).
- Returns:
- Like Stream.toArray(IntFunction).
 
 
-