소스 검색

add findFile to find a file with a specific name

tags/2.0.1
Jonathan Cobb 4 년 전
부모
커밋
95a16abec2
1개의 변경된 파일16개의 추가작업 그리고 0개의 파일을 삭제
  1. +16
    -0
      src/main/java/org/cobbzilla/util/io/FileUtil.java

+ 16
- 0
src/main/java/org/cobbzilla/util/io/FileUtil.java 파일 보기

@@ -608,4 +608,20 @@ public class FileUtil {
}).walk();
return found.get();
}

public static File findFile(File dir, String name) {
final AtomicReference<File> found = new AtomicReference<>(null);
new FilesystemWalker()
.withDir(dir)
.withVisitor(file -> {
if (found.get() != null) return;
if (file.getName().equals(name)) {
synchronized (found) {
if (found.get() == null) found.set(file);
}
}
}).walk();
return found.get();
}

}

불러오는 중...
취소
저장