Hi everyone, whether someone has a solution for deletion downloaded file that has the same text in name and format, but always different number that is generated dynamically in name, for example “example -12.pdf”. So “12” is generated dynamically. And it can be any number, but text “example” is always the same.
It works only for static name files:
String filePath = RunConfiguration.getProjectDir() + ‘/Data Files/’
String path = filePath + importfilename
File file = new File(path)try
{
Files.deleteIfExists(Paths.get(path))
}
catch(NoSuchFileException e)
{
System.out.println(‘No such File/Directory Exists’)
}
catch(DirectoryNotEmptyException e)
{
System.out.println(‘Directory is not Empty.’)
}
catch(IOException e)
{
System.out.println(‘Invalid Permissions.’)
}
System.out.println(‘File Deletion is Successful.’)