Java 8 Stream String Null Or Empty Filter

前端 未结 6 2066
你的背包
你的背包 2021-01-01 09:34

I\'ve got Google Guava inside Stream:

this.map.entrySet().stream()
.filter(entity -> !Strings.isNullOrEmpty(entity.getValue()))
.map(obj -> String.form         


        
6条回答
  •  我在风中等你
    2021-01-01 10:16

    In java 11 there is a new method Predicate::not.

    So you can filter out empty string :

    list.stream()
      .filter(Objects::nonNull)
      .filter(Predicate.not(String::isEmpty))
    

提交回复
热议问题