Skip to content

exclude

Mahmoud Ben Hassine edited this page Nov 21, 2015 · 5 revisions

exclude

Synopsis

Exclude elements matching a predicate from a stream.

This is the opposite behavior of filter.

Parameters

Name Type Mandatory Default
predicate Predicate Yes N/A

Example

Stream<String> stream = Stream.of("a", "b");

UnixStream.unixify(stream)
   .exclude(contains("a"))
   .to(stdOut()); // prints "b"

// Or

UnixStream.from(stream)
   .pipe(exclude(contains("a")))
   .to(stdOut()); // prints "b"

// Or

stream
    .filter(Predicates.exclude(contains("a")))
    .forEach(System.out::println); // prints "b"
Clone this wiki locally