我尝试了以下内容:
List<File> part;
List<File> csvFiles = part.stream().filter(f -> f.getName().endsWith("csv")).collect(Collectors.toList());
但我收到错误&#34; Syntax error on tokens(s), misplaced construct(s)
&#34;
答案 0 :(得分:0)
List<File> filesList = new ArrayList<>();
// retrieve all files and fill the fileList
List<File> csvFiles = new ArrayList<>();
csvFiles = files.stream().filter(file ->
file.getAbsolutePath().contains(".csv")).collect(Collectors.toList());