forEach()
-
람다식으로 특정 확장자 파일명 불러오기 (+ forEach()와 향상된 for문)JAVA/스트림, 컬렉션 프레임워크, 람다 2024. 6. 7. 12:23
▤ 목차" data-ke-type="html">HTML 삽입미리보기할 수 없는 소스 ✔ fileFilter ( 특정 확장자 파일 가져오기 )⌨ 형식public class MyLambda3 { public MyLambda3() { // 람다 표현식 사용 test(); //thread 사용 } private void test() { //특정 디렉토리(폴더)에 있는 파일 목록 걸러보기 File direc = new File("c:/work"); //fileFilter 함수형 인터페이스로 람다식 처리, 확장자 txt만 필터링 File[] files = direc.listFiles((File file) ->file.isFile() && file.getName().endsWith(".txt..