aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/java/org/apache/poi/xssf
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2017-11-23 20:03:25 +0000
committerPJ Fanning <fanningpj@apache.org>2017-11-23 20:03:25 +0000
commite0c8416726efa9ca12e0791aa89295c9e7964cde (patch)
tree4fb344e6046005d88413bab2c429fd221a82796a /src/ooxml/java/org/apache/poi/xssf
parent61cad2865eeb9dff5664ceb47a4e088fe8827b01 (diff)
downloadpoi-e0c8416726efa9ca12e0791aa89295c9e7964cde.tar.gz
poi-e0c8416726efa9ca12e0791aa89295c9e7964cde.zip
use try with resources in examples
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1816189 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java/org/apache/poi/xssf')
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFBReader.java8
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFObjectData.java7
2 files changed, 3 insertions, 12 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFBReader.java b/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFBReader.java
index e3ac6d22a1..b4f2024a24 100644
--- a/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFBReader.java
+++ b/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFBReader.java
@@ -87,14 +87,10 @@ public class XSSFBReader extends XSSFReader {
* @throws IOException when there's a problem with the workbook part's stream
*/
public String getAbsPathMetadata() throws IOException {
- InputStream is = null;
- try {
- is = workbookPart.getInputStream();
- PathExtractor p = new PathExtractor(workbookPart.getInputStream());
+ try (InputStream is = workbookPart.getInputStream()) {
+ PathExtractor p = new PathExtractor(is);
p.parse();
return p.getPath();
- } finally {
- IOUtils.closeQuietly(is);
}
}
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFObjectData.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFObjectData.java
index e54e25fd5f..c20d8d44cc 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFObjectData.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFObjectData.java
@@ -171,14 +171,9 @@ public class XSSFObjectData extends XSSFSimpleShape implements ObjectData {
}
@Override
- @SuppressWarnings("resource")
public DirectoryEntry getDirectory() throws IOException {
- InputStream is = null;
- try {
- is = getObjectPart().getInputStream();
+ try (InputStream is = getObjectPart().getInputStream()) {
return new POIFSFileSystem(is).getRoot();
- } finally {
- IOUtils.closeQuietly(is);
}
}