public class POIFSFileSystem extends NPOIFSFileSystem implements POIFSViewable
POIFSFileSystem
to
OPOIFSFileSystem
, and from NPOIFSFileSystem
to
POIFSFileSystem
.
This has been updated to be powered by the NIO-based NPOIFS
NPOIFSFileSystem
.
BlockStore.ChainLoopDetector
Constructor and Description |
---|
POIFSFileSystem()
Constructor, intended for writing
|
POIFSFileSystem(java.io.File file)
Creates a POIFSFileSystem from a File.
|
POIFSFileSystem(java.io.File file,
boolean readOnly)
Creates a POIFSFileSystem from a File.
|
POIFSFileSystem(java.io.InputStream stream)
Create a POIFSFileSystem from an InputStream.
|
Modifier and Type | Method and Description |
---|---|
static POIFSFileSystem |
create(java.io.File file)
Creates a new
POIFSFileSystem in a new File . |
static java.io.InputStream |
createNonClosingInputStream(java.io.InputStream is)
Convenience method for clients that want to avoid the auto-close behaviour of the constructor.
|
static void |
main(java.lang.String[] args)
read in a file and write it back out again
|
close, createBlockIfNeeded, createDirectory, createDocument, createDocument, createDocumentInputStream, createOrUpdateDocument, getBATBlockAndIndex, getBigBlockSize, getBigBlockSizeDetails, getBlockAt, getBlockStoreBlockSize, getChainLoopDetector, getFreeBlock, getHeaderBlock, getMiniStore, getNextBlock, getPropertyTable, getRoot, getShortDescription, getViewableArray, getViewableIterator, hasPOIFSHeader, hasPOIFSHeader, isInPlaceWriteable, preferArray, setNextBlock, size, writeFilesystem, writeFilesystem
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getShortDescription, getViewableArray, getViewableIterator, preferArray
public POIFSFileSystem()
public POIFSFileSystem(java.io.InputStream stream) throws java.io.IOException
Some streams are usable after reaching EOF (typically those that return true
for markSupported()). In the unlikely case that the caller has such a stream
and needs to use it after this constructor completes, a work around is to wrap the
stream in order to trap the close() call. A convenience method (
createNonClosingInputStream()) has been provided for this purpose:
InputStream wrappedStream = POIFSFileSystem.createNonClosingInputStream(is); HSSFWorkbook wb = new HSSFWorkbook(wrappedStream); is.reset(); doSomethingElse(is);Note also the special case of ByteArrayInputStream for which the close() method does nothing.
ByteArrayInputStream bais = ... HSSFWorkbook wb = new HSSFWorkbook(bais); // calls bais.close() ! bais.reset(); // no problem doSomethingElse(bais);
stream
- the InputStream from which to read the datajava.io.IOException
- on errors reading, or on invalid datapublic POIFSFileSystem(java.io.File file, boolean readOnly) throws java.io.IOException
Creates a POIFSFileSystem from a File. This uses less memory than creating from an InputStream.
Note that with this constructor, you will need to call NPOIFSFileSystem.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.
readOnly
- whether the POIFileSystem will only be used in read-only modefile
- the File from which to read the datajava.io.IOException
- on errors reading, or on invalid datapublic POIFSFileSystem(java.io.File file) throws java.io.IOException
Creates a POIFSFileSystem from a File. This uses less memory than creating from an InputStream. The File will be opened read-only
Note that with this constructor, you will need to call NPOIFSFileSystem.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.
file
- the File from which to read the datajava.io.IOException
- on errors reading, or on invalid datapublic static java.io.InputStream createNonClosingInputStream(java.io.InputStream is)
public static POIFSFileSystem create(java.io.File file) throws java.io.IOException
POIFSFileSystem
in a new File
.
Use POIFSFileSystem(File)
to open an existing File,
this should only be used to create a new empty filesystem.file
- The file to create and openPOIFSFileSystem
java.io.IOException
public static void main(java.lang.String[] args) throws java.io.IOException
args
- names of the files; arg[ 0 ] is the input file,
arg[ 1 ] is the output filejava.io.IOException
Copyright 2018 The Apache Software Foundation or its licensors, as applicable.