ソースを参照

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();
}

}

読み込み中…
キャンセル
保存