From b82153a9a3bd49b11aaf1f20c07737a0dd5f55f9 Mon Sep 17 00:00:00 2001 From: Oliver Imlinger Date: Thu, 28 Sep 2023 10:04:22 +0200 Subject: [PATCH] https://github.com/aim42/htmlSanityCheck/issues/305 --- .../report/HtmlReporter.groovy | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/groovy/org/aim42/htmlsanitycheck/report/HtmlReporter.groovy b/src/main/groovy/org/aim42/htmlsanitycheck/report/HtmlReporter.groovy index 88de5c94..73172d25 100644 --- a/src/main/groovy/org/aim42/htmlsanitycheck/report/HtmlReporter.groovy +++ b/src/main/groovy/org/aim42/htmlsanitycheck/report/HtmlReporter.groovy @@ -5,7 +5,13 @@ import groovy.util.logging.Slf4j import org.aim42.htmlsanitycheck.collect.PerRunResults import org.aim42.htmlsanitycheck.collect.SingleCheckResults import org.aim42.htmlsanitycheck.collect.SinglePageResults -import org.gradle.util.GFileUtils + +import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; /** * write the findings report to HTML @@ -63,9 +69,21 @@ public class HtmlReporter extends Reporter { */ private void copyResourceFromJarToDirectory(String resourceName, File outputDirectory) { URL resource = getClass().getClassLoader().getResource(resourceName); - // String dir = StringUtils.substringAfterLast(resourceName, "."); - //GFileUtils.copyURLToFile(resource, new File(outputDirectory, dir + "/" + resourceName)); - GFileUtils.copyURLToFile(resource, new File(outputDirectory, resourceName)); + + // https://github.com/aim42/htmlSanityCheck/issues/305 + InputStream stream = null; + try { + stream = resource.openStream() + Files.copy(stream, new File(outputDirectory, resourceName).toPath(), StandardCopyOption.REPLACE_EXISTING); + } catch (final IOException e) { + throw new UncheckedIOException(e); + } finally { + try { + stream.close(); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } }