In my case, when my SOAP request is polled, there will be few files generated in c:/storage/fghjk/
folder.
When I send the request again, another random folder will be created and the files be created there. (c:/storage/ngjdhd/
)
Any idea How I can handle my code to handle this randomly generated folder?
I tried using regex but failed. Finally ended up with some inefficient code. which I am not happy about.
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 + "\"");
}