Skip to content
Mahmoud Ben Hassine edited this page Oct 9, 2015 · 4 revisions

grep

Synopsis

Keeps elements containing a given pattern in a stream of Strings.

Parameters

Name Type Mandatory Default
pattern String Yes N/A

Example

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

XStream.unixify(stream)
   .grep("a")
   .to(stdOut()); // prints "a", "ab"

// Or

XStream.from(stream)
   .pipe(grep("a"))
   .to(stdOut()); // prints "a", "ab"
Clone this wiki locally