Constructor and Description |
---|
StreamUtil() |
Modifier and Type | Method and Description |
---|---|
static <T> String |
join(Stream<T> stream,
CharSequence delimiter)
将Stream中所有元素以指定分隔符,合并为一个字符串,对象默认调用toString方法
|
static <T> String |
join(Stream<T> stream,
CharSequence delimiter,
Function<T,? extends CharSequence> toStringFunc)
将Stream中所有元素以指定分隔符,合并为一个字符串
|
static Stream<String> |
of(File file)
按行读取文件为
Stream |
static Stream<String> |
of(File file,
Charset charset)
按行读取文件为
Stream |
static <T> Stream<T> |
of(Iterable<T> iterable)
|
static <T> Stream<T> |
of(Iterable<T> iterable,
boolean parallel)
|
static <T> Stream<T> |
of(Iterator<T> iterator)
|
static <T> Stream<T> |
of(Iterator<T> iterator,
boolean parallel)
|
static Stream<String> |
of(Path path)
按行读取文件为
Stream |
static Stream<String> |
of(Path path,
Charset charset)
按行读取文件为
Stream |
static <T> Stream<T> |
of(T... array) |
static <T> Stream<T> |
of(T seed,
UnaryOperator<T> elementCreator,
int limit)
通过函数创建Stream
|
@SafeVarargs public static <T> Stream<T> of(T... array)
public static <T> Stream<T> of(Iterable<T> iterable)
T
- 集合元素类型iterable
- 集合Stream
public static <T> Stream<T> of(Iterable<T> iterable, boolean parallel)
T
- 集合元素类型iterable
- 集合parallel
- 是否并行Stream
public static <T> Stream<T> of(Iterator<T> iterator)
T
- 集合元素类型iterator
- 迭代器Stream
IllegalArgumentException
- 如果iterator为null,抛出该异常public static <T> Stream<T> of(Iterator<T> iterator, boolean parallel)
T
- 集合元素类型iterator
- 迭代器parallel
- 是否并行Stream
IllegalArgumentException
- 如果iterator为null,抛出该异常public static Stream<String> of(File file, Charset charset)
Stream
file
- 文件charset
- 编码Stream
public static Stream<String> of(Path path, Charset charset)
Stream
path
- 路径charset
- 编码Stream
public static <T> Stream<T> of(T seed, UnaryOperator<T> elementCreator, int limit)
T
- 创建元素类型seed
- 初始值elementCreator
- 递进函数,每次调用此函数获取下一个值limit
- 限制个数Stream
public static <T> String join(Stream<T> stream, CharSequence delimiter)
T
- 元素类型stream
- Stream
delimiter
- 分隔符public static <T> String join(Stream<T> stream, CharSequence delimiter, Function<T,? extends CharSequence> toStringFunc)
T
- 元素类型stream
- Stream
delimiter
- 分隔符toStringFunc
- 元素转换为字符串的函数Copyright © 2024. All rights reserved.