]> source.dussan.org Git - poi.git/commitdiff
Patch from Daniel Bonniot from bug #56956 - Add a NPOIFSFileSystem constructor with...
authorNick Burch <nick@apache.org>
Thu, 11 Sep 2014 08:48:10 +0000 (08:48 +0000)
committerNick Burch <nick@apache.org>
Thu, 11 Sep 2014 08:48:10 +0000 (08:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1624226 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java

index 6099bb1ece4fdf8a7e9ceffa833afcbed6bc5156..fd3529af3a8d0386f28f4f1dadf054c1a2040410 100644 (file)
@@ -153,7 +153,8 @@ public class NPOIFSFileSystem extends BlockStore
      *  when you're done to have the underlying file closed, as the file is
      *  kept open during normal operation to read the data out.</p> 
      *  
-     * @param file the File from which to read the data
+     * @param file the File from which to read or read/write the data
+     * @param readOnly whether the POIFileSystem will only be used in read-only mode
      *
      * @exception IOException on errors reading, or on invalid data
      */
@@ -165,7 +166,8 @@ public class NPOIFSFileSystem extends BlockStore
     
     /**
      * <p>Creates a POIFSFileSystem from an open <tt>FileChannel</tt>. This uses 
-     *  less memory than creating from an <tt>InputStream</tt>.</p>
+     *  less memory than creating from an <tt>InputStream</tt>. The stream will
+     *  be used in read-write mode.</p>
      *  
      * <p>Note that with this constructor, you will need to call {@link #close()}
      *  when you're done to have the underlying Channel closed, as the channel is
@@ -181,6 +183,25 @@ public class NPOIFSFileSystem extends BlockStore
        this(channel, null, false, false);
     }
     
+    /**
+     * <p>Creates a POIFSFileSystem from an open <tt>FileChannel</tt>. This uses 
+     *  less memory than creating from an <tt>InputStream</tt>.</p>
+     *  
+     * <p>Note that with this constructor, you will need to call {@link #close()}
+     *  when you're done to have the underlying Channel closed, as the channel is
+     *  kept open during normal operation to read the data out.</p> 
+     *  
+     * @param channel the FileChannel from which to read or read/write the data
+     * @param readOnly whether the POIFileSystem will only be used in read-only mode
+     *
+     * @exception IOException on errors reading, or on invalid data
+     */
+    public NPOIFSFileSystem(FileChannel channel, boolean readOnly)
+         throws IOException
+    {
+       this(channel, null, readOnly, false);
+    }
+    
     private NPOIFSFileSystem(FileChannel channel, File srcFile, boolean readOnly, boolean closeChannelOnError)
          throws IOException
     {