diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/service/GradBusinessService.java b/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/service/GradBusinessService.java index 3e71b16..57d58f2 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/service/GradBusinessService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/service/GradBusinessService.java @@ -367,9 +367,9 @@ private void saveBinaryResponseToFile(byte[] resultBinary, String reportFile) th String pathToFile = TMP + File.separator + reportFile; logger.debug("Save generated PDF {} on the file system", reportFile); File fileToSave = new File(pathToFile); - if(fileToSave.exists()) { - boolean isDeleted = fileToSave.delete(); - logger.debug("{} to delete existing PDF {}", isDeleted, reportFile); + boolean isDeleted = Files.deleteIfExists(fileToSave.toPath()); + if(isDeleted) { + logger.debug("Delete existing PDF {}", reportFile); } Files.write(fileToSave.toPath(), resultBinary); logger.debug("PDF {} saved successfully", pathToFile);