| 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 - 集合Streampublic static <T> Stream<T> of(Iterable<T> iterable, boolean parallel)
T - 集合元素类型iterable - 集合parallel - 是否并行Streampublic static <T> Stream<T> of(Iterator<T> iterator)
T - 集合元素类型iterator - 迭代器StreamIllegalArgumentException - 如果iterator为null,抛出该异常public static <T> Stream<T> of(Iterator<T> iterator, boolean parallel)
T - 集合元素类型iterator - 迭代器parallel - 是否并行StreamIllegalArgumentException - 如果iterator为null,抛出该异常public static Stream<String> of(File file, Charset charset)
Streamfile - 文件charset - 编码Streampublic static Stream<String> of(Path path, Charset charset)
Streampath - 路径charset - 编码Streampublic static <T> Stream<T> of(T seed, UnaryOperator<T> elementCreator, int limit)
T - 创建元素类型seed - 初始值elementCreator - 递进函数,每次调用此函数获取下一个值limit - 限制个数Streampublic static <T> String join(Stream<T> stream, CharSequence delimiter)
T - 元素类型stream - Streamdelimiter - 分隔符public static <T> String join(Stream<T> stream, CharSequence delimiter, Function<T,? extends CharSequence> toStringFunc)
T - 元素类型stream - Streamdelimiter - 分隔符toStringFunc - 元素转换为字符串的函数Copyright © 2025. All rights reserved.