package com.tc.test; import org.junit.Test; import java.io.File; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import static java.lang.System.out; public class TestLambdaStream { String filePath = "D:\\android_werkspace"; @Test public void testLambda(){ File file = new File(filePath); if (file.exists() && file.isDirectory()){ String[] target = file.list(((a, name) -> { if (name.endsWith(".gradle")){ return true; } return false; })); for (String fileName : target) { out.println(fileName); } } } @Test public void testStream(){ File file = new File(filePath); if (file.exists() && file.isDirectory()){ List<String> targ
file.list遍历文件夹找出包含指定内容的文件名的几种方法记录
最新推荐文章于 2021-08-18 13:12:57 发布