Skip to content
Mahmoud Ben Hassine edited this page Nov 21, 2015 · 4 revisions

fold

Synopsis

Folds Strings with a given width in a stream of Strings.

Parameters

Name Type Mandatory Default
width int No 80

Example

Stream<String> stream = Stream.of("abc", "def");

UnixStream.unixify(stream)
   .fold(2)
   .to(stdOut());
/* prints:
ab
c
de
f
*/

// Or

UnixStream.from(stream)
   .pipe(fold(2))
   .to(stdOut());
/* prints:
ab
c
de
f
*/

// Or

stream
    .map(Functions.fold(2))
    .forEach(System.out::println);
/* prints:
ab
c
de
f
*/
Clone this wiki locally