diff options
author | PJ Fanning <fanningpj@apache.org> | 2021-12-29 13:08:56 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2021-12-29 13:08:56 +0000 |
commit | 6784dd81c2abc907e98e49450f39e9475ffb09b0 (patch) | |
tree | 9a8ca4114fe58f09cd8a4e91beecd0d23b67766a /poi-examples/src | |
parent | 79a1e6b1e90c613958f91739f15c5f8512f7ee0b (diff) | |
download | poi-6784dd81c2abc907e98e49450f39e9475ffb09b0.tar.gz poi-6784dd81c2abc907e98e49450f39e9475ffb09b0.zip |
update some code based on sonar issues
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1896504 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-examples/src')
-rw-r--r-- | poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/BigGridDemo.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/BigGridDemo.java b/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/BigGridDemo.java index bca850186d..06bc962d5d 100644 --- a/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/BigGridDemo.java +++ b/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/BigGridDemo.java @@ -34,6 +34,8 @@ import java.util.Random; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; import org.apache.commons.compress.archivers.zip.ZipFile; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.poi.openxml4j.opc.internal.ZipHelper; import org.apache.poi.ss.usermodel.DateUtil; import org.apache.poi.ss.usermodel.FillPatternType; @@ -73,6 +75,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; * See <a href="https://poi.apache.org/spreadsheet/how-to.html#sxssf">SXSSF (Streaming Usermodel API)</a>. */ public final class BigGridDemo { + private static final Logger LOG = LogManager.getLogger(BigGridDemo.class); private static final String XML_ENCODING = "UTF-8"; private static final Random rnd = new Random(); @@ -111,7 +114,11 @@ public final class BigGridDemo { substitute(new File("template.xlsx"), tmp, sheetRef.substring(1), out); } } finally { - if (tmp != null) tmp.delete(); + if (tmp != null && tmp.exists()) { + if (!tmp.delete()) { + LOG.atInfo().log("failed to delete temp file"); + } + } } } |