就我而言,当我的SOAP请求被轮询时,c:/storage/fghjk/
文件夹中将生成很少的文件。
当我再次发送请求时,将创建另一个随机文件夹,并在此处创建文件。 (c:/storage/ngjdhd/
)
有什么主意我该如何处理我的代码以处理此随机生成的文件夹?
我尝试使用正则表达式,但失败了。最终以一些低效率的代码结束。我不满意。
String randomFolder = null;
for (String fileToCheck : files) {
File folder = new File(location);
File[] listOfFiles = folder.listFiles();
if (listOfFiles[0].isDirectory()) {
randomFolder = listOfFiles[0].getName();
}
String filePath = location + "/" + randomFolder + "/" + fileToCheck.trim();
File currentFile = new File(FilenameUtils.normalize(filePath, Boolean.TRUE));
assertTrue(currentFile.exists(), "Existence of file \"" + currentFile + "\"");
}