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
This commit is contained in:
Nick Burch 2010-12-30 00:58:28 +00:00
parent 2f466d27fe
commit c82f06605e
1 changed files with 14 additions and 1 deletions

View File

@ -107,7 +107,11 @@ public class NPOIFSFileSystem extends BlockStore
/**
* Creates a POIFSFileSystem from a <tt>File</tt>. This uses less memory than
* creating from an <tt>InputStream</tt>
* creating from an <tt>InputStream</tt>.
*
* 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