From e34e77b12d6d39ffd2a070e9672dcbbec37e8633 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Wed, 2 Jul 2014 15:05:05 +0000 Subject: [PATCH] Bug 56537: Update javadoc to reflect the addition of Closeable to Workbook git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1607390 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/poifs/filesystem/NPOIFSFileSystem.java | 1 - .../apache/poi/ss/usermodel/WorkbookFactory.java | 13 +++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java b/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java index 0de0bfdc0..6099bb1ec 100644 --- a/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java +++ b/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java @@ -157,7 +157,6 @@ public class NPOIFSFileSystem extends BlockStore * * @exception IOException on errors reading, or on invalid data */ - @SuppressWarnings("resource") public NPOIFSFileSystem(File file, boolean readOnly) throws IOException { diff --git a/src/ooxml/java/org/apache/poi/ss/usermodel/WorkbookFactory.java b/src/ooxml/java/org/apache/poi/ss/usermodel/WorkbookFactory.java index eeb24a4eb..b17a1a5aa 100644 --- a/src/ooxml/java/org/apache/poi/ss/usermodel/WorkbookFactory.java +++ b/src/ooxml/java/org/apache/poi/ss/usermodel/WorkbookFactory.java @@ -39,6 +39,8 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class WorkbookFactory { /** * Creates a HSSFWorkbook from the given POIFSFileSystem + *

Note that in order to properly release resources the + * Workbook should be closed after use. */ public static Workbook create(POIFSFileSystem fs) throws IOException { return new HSSFWorkbook(fs); @@ -46,6 +48,8 @@ public class WorkbookFactory { /** * Creates a HSSFWorkbook from the given NPOIFSFileSystem + *

Note that in order to properly release resources the + * Workbook should be closed after use. */ public static Workbook create(NPOIFSFileSystem fs) throws IOException { return new HSSFWorkbook(fs.getRoot(), true); @@ -53,6 +57,8 @@ public class WorkbookFactory { /** * Creates a XSSFWorkbook from the given OOXML Package + *

Note that in order to properly release resources the + * Workbook should be closed after use. */ public static Workbook create(OPCPackage pkg) throws IOException { return new XSSFWorkbook(pkg); @@ -65,6 +71,8 @@ public class WorkbookFactory { * be wrapped as a {@link PushbackInputStream}! Note that * using an {@link InputStream} has a higher memory footprint * than using a {@link File}.

+ *

Note that in order to properly release resources the + * Workbook should be closed after use. */ public static Workbook create(InputStream inp) throws IOException, InvalidFormatException { // If clearly doesn't do mark/reset, wrap up @@ -84,8 +92,8 @@ public class WorkbookFactory { /** * Creates the appropriate HSSFWorkbook / XSSFWorkbook from * the given File, which must exist and be readable. - *

Note that for Workbooks opened this way, it is not possible - * to explicitly close the underlying File resource. + *

Note that in order to properly release resources the + * Workbook should be closed after use. */ public static Workbook create(File file) throws IOException, InvalidFormatException { if (! file.exists()) { @@ -93,6 +101,7 @@ public class WorkbookFactory { } try { + @SuppressWarnings("resource") NPOIFSFileSystem fs = new NPOIFSFileSystem(file); return new HSSFWorkbook(fs.getRoot(), true); } catch(OfficeXmlFileException e) {