Author: fanningpj
Date: Thu Jun 7 06:03:35 2018
New Revision: 1833096
URL: http://svn.apache.org/viewvc?rev=1833096&view=rev
Log:
use try with resources
Modified:
poi/trunk/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java
Modified: poi/trunk/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java?rev=1833096&r1=1833095&r2=1833096&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java
(original)
+++ poi/trunk/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java Thu Jun
7 06:03:35 2018
@@ -83,24 +83,24 @@ public class VBAMacroReader implements C
}
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");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]