Skip to content

Instantly share code, notes, and snippets.

@programsimon
Created March 12, 2023 07:26
Show Gist options
  • Select an option

  • Save programsimon/8dab86c591800947584af21825084275 to your computer and use it in GitHub Desktop.

Select an option

Save programsimon/8dab86c591800947584af21825084275 to your computer and use it in GitHub Desktop.
[Java Stream 流使用] #stream
public void stream(){
List<String> myList =
Arrays.asList("a1", "a2", "b1", "c2", "c1");
//查找第一个符合条件的
myList
.stream()
.filter(x -> x.getClass().equals(StringHttpMessageConverter.class))
.findFirst()
.orElse(null);
//根据条件过滤,获取所有符合条件的元素集合
Arrays.stream(clazz.getMethods())
.filter(m -> m.getName().equalsIgnoreCase(methodName))
.filter(m -> Modifier.isPublic(m.getModifiers()))
.collect(Collectors.toList());
//遍历每个元素
cachedWorkbook.values()
.forEach(w -> FileUtils.deleteFile(w.cachedFileName));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment