將迭代器轉換為流
使用 Spliterators.spliterator()
或 Spliterators.spliteratorUnknownSize()
將迭代器轉換為流:
Iterator<String> iterator = Arrays.asList("A", "B", "C").iterator();
Spliterator<String> spliterator = Spliterators.spliteratorUnknownSize(iterator, 0);
Stream<String> stream = StreamSupport.stream(spliterator, false);