How to check a file if exists with wildcard in Java?

前端 未结 7 683
谎友^
谎友^ 2020-11-27 21:34

I have a directory, and inside it are files are named \"a_id_XXX.zip\".

How do check if a file exists given an id and File dir

7条回答
  •  半阙折子戏
    2020-11-27 21:50

    Java 7 has some good support for pattern matching (PathMatcher) and recursive directory walking (Files.walkFileTree()). In the context of the original question, this page in Oracle's Java documentation is a good start:

    Finding Files: http://docs.oracle.com/javase/tutorial/essential/io/find.html

提交回复
热议问题