mirror of https://github.com/apache/poi.git
use try with resources
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1833096 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1ba74b1da9
commit
bb15bf3aef
|
@ -83,24 +83,24 @@ public class VBAMacroReader implements Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openOOXML(InputStream zipFile) throws IOException {
|
private void openOOXML(InputStream zipFile) throws IOException {
|
||||||
ZipInputStream zis = new ZipInputStream(zipFile);
|
try(ZipInputStream zis = new ZipInputStream(zipFile)) {
|
||||||
ZipEntry zipEntry;
|
ZipEntry zipEntry;
|
||||||
while ((zipEntry = zis.getNextEntry()) != null) {
|
while ((zipEntry = zis.getNextEntry()) != null) {
|
||||||
if (endsWithIgnoreCase(zipEntry.getName(), VBA_PROJECT_OOXML)) {
|
if (endsWithIgnoreCase(zipEntry.getName(), VBA_PROJECT_OOXML)) {
|
||||||
try {
|
try {
|
||||||
// Make a NPOIFS from the contents, and close the stream
|
// Make a NPOIFS from the contents, and close the stream
|
||||||
this.fs = new NPOIFSFileSystem(zis);
|
this.fs = new NPOIFSFileSystem(zis);
|
||||||
return;
|
return;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// Tidy up
|
// Tidy up
|
||||||
zis.close();
|
zis.close();
|
||||||
|
|
||||||
// Pass on
|
// Pass on
|
||||||
throw e;
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
zis.close();
|
|
||||||
throw new IllegalArgumentException("No VBA project found");
|
throw new IllegalArgumentException("No VBA project found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue