wil*_*hos 0 java glob file path
我需要读取一个具有动态名称的 xml 文件。文件名类似于“1234_employees.xml”,其中的数字每天都在变化。文件夹中只有一个 .xml。
没有 正则表达式 这适用于文件/路径?
就像是:
File myxml = new File("*employees.xml");
Run Code Online (Sandbox Code Playgroud)
您可以使用WildcardFileFilter:
File dir = new File(".");
FileFilter fileFilter = new WildcardFileFilter("*employees.xml");
File employeesXml = dir.listFiles(fileFilter)[0];
Run Code Online (Sandbox Code Playgroud)
你需要安装这个库:
https://mvnrepository.com/artifact/org.apache.commons/commons-io/1.3.2