From f02e062521ea73e59dd5e95a52cb6a71b0f77c1d Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Thu, 30 Dec 2010 00:58:28 +0000 Subject: [PATCH] NPOIFS needs an explicit close, as it has to keep the File / buffer around to read from. Adds a close method git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1053777 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/poifs/filesystem/NPOIFSFileSystem.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java b/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java index b506e4b9aa..e671d870bb 100644 --- a/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java +++ b/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java @@ -107,7 +107,11 @@ public class NPOIFSFileSystem extends BlockStore /** * Creates a POIFSFileSystem from a File. This uses less memory than - * creating from an InputStream + * creating from an InputStream. + * + * Note that with this constructor, you will need to call {@link #close()} + * when you're done to have the underlying file closed, as the file is + * kept open during normal operation to read the data out. * * @param file the File from which to read the data * @@ -625,6 +629,15 @@ public class NPOIFSFileSystem extends BlockStore new NPOIFSStream(this, _header.getPropertyStart()) ); } + + /** + * Closes the FileSystem, freeing any underlying files, streams + * and buffers. After this, you will be unable to read or + * write from the FileSystem. + */ + public void close() throws IOException { + _data.close(); + } /** * read in a file and write it back out again -- 2.39.5