java: search file according to its name in directory and subdirectories

前端 未结 5 1014
庸人自扰
庸人自扰 2021-02-03 13:50

I need a to find file according to its name in directory tree. And then show a path to this file. I found something like this, but it search according extension. Could anybody h

5条回答
  •  名媛妹妹
    2021-02-03 13:50

    Recursive directory search in Java is pretty darn easy. The java.io.File class has a listFiles() method that gives all the File children of a directory; there's also an isDirectory() method you call on a File to determine whether you should recursively search through a particular child.

提交回复
热议问题