aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2018-06-07 06:03:35 +0000
committerPJ Fanning <fanningpj@apache.org>2018-06-07 06:03:35 +0000
commitbb15bf3aef1628060061d90c9fa69c6c68e4600f (patch)
tree2dbd4b67d94c97457bdd01d2e3a859ee9badb036 /src/java
parent1ba74b1da9fe663fb221b7f146ded500148b96c3 (diff)
downloadpoi-bb15bf3aef1628060061d90c9fa69c6c68e4600f.tar.gz
poi-bb15bf3aef1628060061d90c9fa69c6c68e4600f.zip
use try with resources
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1833096 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/poi/poifs/macros/VBAMacroReader.java30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java b/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java
index 8b5e1ac588..6a5fa620a7 100644
--- a/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java
+++ b/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java
@@ -83,24 +83,24 @@ public class VBAMacroReader implements Closeable {
}
private void openOOXML(InputStream zipFile) throws IOException {
- ZipInputStream zis = new ZipInputStream(zipFile);
- ZipEntry zipEntry;
- while ((zipEntry = zis.getNextEntry()) != null) {
- if (endsWithIgnoreCase(zipEntry.getName(), VBA_PROJECT_OOXML)) {
- try {
- // Make a NPOIFS from the contents, and close the stream
- this.fs = new NPOIFSFileSystem(zis);
- return;
- } catch (IOException e) {
- // Tidy up
- zis.close();
-
- // Pass on
- throw e;
+ try(ZipInputStream zis = new ZipInputStream(zipFile)) {
+ ZipEntry zipEntry;
+ while ((zipEntry = zis.getNextEntry()) != null) {
+ if (endsWithIgnoreCase(zipEntry.getName(), VBA_PROJECT_OOXML)) {
+ try {
+ // Make a NPOIFS from the contents, and close the stream
+ this.fs = new NPOIFSFileSystem(zis);
+ return;
+ } catch (IOException e) {
+ // Tidy up
+ zis.close();
+
+ // Pass on
+ throw e;
+ }
}
}
}
- zis.close();
throw new IllegalArgumentException("No VBA project found");
}