From ff1cad995dc61be3a33c0c02649d23cc143faf60 Mon Sep 17 00:00:00 2001 From: Melloware Date: Sun, 6 Nov 2022 07:40:12 -0500 Subject: [PATCH 1/2] Fix #2770: FileAlreadyExistsException on copy --- testng-core/src/main/java/org/testng/reporters/jq/Main.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testng-core/src/main/java/org/testng/reporters/jq/Main.java b/testng-core/src/main/java/org/testng/reporters/jq/Main.java index b0bc7ba093..19e0ca0b6b 100644 --- a/testng-core/src/main/java/org/testng/reporters/jq/Main.java +++ b/testng-core/src/main/java/org/testng/reporters/jq/Main.java @@ -92,7 +92,7 @@ public void generateReport( } File fileToCopy = new File(outputDirectory, fileName); fileToCopy.getParentFile().mkdirs(); - java.nio.file.Files.copy(is, fileToCopy.toPath()); + java.nio.file.Files.copy(is, fileToCopy.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING); } } all = Files.readFile(header); From ef975f18259f3ce9c822376664f55710bd5167da Mon Sep 17 00:00:00 2001 From: Melloware Date: Sun, 6 Nov 2022 07:49:01 -0500 Subject: [PATCH 2/2] Update Main.java --- testng-core/src/main/java/org/testng/reporters/jq/Main.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testng-core/src/main/java/org/testng/reporters/jq/Main.java b/testng-core/src/main/java/org/testng/reporters/jq/Main.java index 19e0ca0b6b..7c6a959bd0 100644 --- a/testng-core/src/main/java/org/testng/reporters/jq/Main.java +++ b/testng-core/src/main/java/org/testng/reporters/jq/Main.java @@ -92,7 +92,8 @@ public void generateReport( } File fileToCopy = new File(outputDirectory, fileName); fileToCopy.getParentFile().mkdirs(); - java.nio.file.Files.copy(is, fileToCopy.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING); + java.nio.file.Files.copy( + is, fileToCopy.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING); } } all = Files.readFile(header);