This is the main class of the POIFS system; it manages the entire life cycle of the filesystem.
This is the new NIO version, which uses less memory
| Modifier and Type | Field and Description |
|---|---|
| private final List | |
| protected DataSource | |
| private HeaderBlock | |
| private POIFSMiniStore | |
| private PropertyTable | |
| private DirectoryNode | |
| private final List | |
| private POIFSBigBlockSize | bigBlockSize
What big block size the file uses. |
| private static final int | |
| private static final Logger | |
| private static final int | |
| private static final int | MAX_BLOCK_COUNT
Maximum number size (in blocks) of the allocation table as supported by POI. |
| private static int |
| Access | Constructor and Description |
|---|---|
| private | |
| public | |
| public | POIFSFileSystem(File
the File from which to read the data file)Creates a POIFSFileSystem from a |
| public | POIFSFileSystem(File
the File from which to read or read/write the data file, boolean whether the POIFileSystem will only be used in read-only mode readOnly)Creates a POIFSFileSystem from a |
| public | POIFSFileSystem(FileChannel
the FileChannel from which to read the data channel)Creates a POIFSFileSystem from an open |
| public | POIFSFileSystem(FileChannel
the FileChannel from which to read or read/write the data channel, boolean whether the POIFileSystem will only be used in read-only mode readOnly)Creates a POIFSFileSystem from an open |
| public | POIFSFileSystem(FileChannel
the FileChannel from which to read or read/write the data channel, boolean whether the POIFileSystem will only be used in read-only mode readOnly, boolean whether the provided FileChannel should be closed when
closeChannel)close() is called, or when this constructor throws
an exceptionCreates a POIFSFileSystem from an open |
| private | POIFSFileSystem(FileChannel channel, File srcFile, boolean readOnly, boolean closeChannelOnError, boolean closeChannelOnClose)
|
| public | POIFSFileSystem(InputStream
the InputStream from which to read the data stream)Create a POIFSFileSystem from an |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv PropertyTable | |
| pack-priv void | addDirectory(final DirectoryProperty
the DirectoryProperty being added directory)add a new DirectoryProperty to the FileSystem |
| pack-priv void | addDocument(final POIFSDocument
the POIFSDocument being added document)add a new POIFSDocument to the FileSytem |
| public void | close()
Implements java. Closes the FileSystem, freeing any underlying files, streams and buffers. |
| private void | closeInputStream(InputStream
the stream to be closed stream, boolean false if an exception is currently being thrown in the calling method
|
| public static POIFSFileSystem | |
| private BATBlock | |
| protected ByteBuffer | createBlockIfNeeded(final int offset)
Implements abstract org. Load the block at the given offset, extending the file if needed |
| public DirectoryEntry | Returns: the new DirectoryEntrythe name of the new DirectoryEntry name)create a new DirectoryEntry in the root directory |
| public DocumentEntry | Returns: the new DocumentEntrythe InputStream from which the document's data
will be obtained stream, final String the name of the new POIFSDocument name)Create a new document to be added to the root directory |
| public DocumentEntry | Returns: the new DocumentEntrythe name of the new DocumentEntry name, final int the size of the new DocumentEntry size, final POIFSWriterListener the writer of the new DocumentEntry writer)create a new DocumentEntry in the root entry; the data will be provided later |
| public DocumentInputStream | Returns: a newly opened DocumentInputStreamthe name of the document to be opened documentName)open a document in the root entry's list of entries |
| protected void | |
| public DocumentEntry | Returns: the new or updated DocumentEntrythe InputStream from which the document's data
will be obtained stream, final String the name of the new or existing POIFSDocument name)Set the contents of a document in the root directory, creating if needed, otherwise updating |
| protected BATBlock. | getBATBlockAndIndex(final int offset)
Implements abstract org. Returns the BATBlock that handles the specified offset, and the relative index within it |
| public int | |
| public POIFSBigBlockSize | |
| protected ByteBuffer | getBlockAt(final int offset)
Implements abstract org. Load the block at the given offset. |
| protected int | getBlockStoreBlockSize()
Implements abstract org. Returns the size of the blocks managed through the block store. |
| protected BlockStore. | getChainLoopDetector()
Implements abstract org. Creates a Detector for loops in the chain |
| protected int | getFreeBlock()
Implements abstract org. Finds a free block, and returns its offset. |
| public HeaderBlock | |
| public static int | |
| pack-priv POIFSMiniStore | getMiniStore()
Returns the MiniStore, which performs a similar low level function to this, except for the small blocks. |
| protected int | getNextBlock(final int offset)
Implements abstract org. Works out what block follows the specified one. |
| public PropertyTable | |
| public DirectoryNode | |
| public String | Returns: short descriptionImplements org. Provides a short description of the object, to be used when a POIFSViewable object has not provided its contents. |
| public Object[] | Returns: an array of Object; may not be null, but may be emptyImplements org. Get an array of objects, some of which may implement POIFSViewable |
| public Iterator | Returns: an Iterator; may not be null, but may have an empty back end storeImplements org. Get an Iterator of objects, some of which may implement POIFSViewable |
| public boolean | |
| public static void | |
| public boolean | Returns: true if a viewer should call getViewableArray, false if a viewer should call getViewableIteratorImplements org. Give viewers a hint as to whether to call getViewableArray or getViewableIterator |
| private void | |
| private void | readCoreContents()
Read and process the PropertiesTable and the FAT / XFAT blocks, so that we're ready to work with the file |
| protected void | releaseBuffer(ByteBuffer
the buffer buffer)Implements abstract org. Releases a mmap-ed buffer, which you are sure won't be used again |
| pack-priv void | |
| private static void | |
| public static void | |
| protected void | setNextBlock(final int offset, final int nextBlock)
Implements abstract org. Changes the record of what block follows the specified one. |
| protected long | |
| private void | |
| public void | |
| public void | writeFilesystem(final OutputStream
the OutputStream to which the filesystem will be
written stream)Write the filesystem out |
| _bat_blocks | back to summary |
|---|---|
| private final List<BATBlock> _bat_blocks | |
| _data | back to summary |
|---|---|
| protected DataSource _data | |
| _header | back to summary |
|---|---|
| private HeaderBlock _header | |
| _mini_store | back to summary |
|---|---|
| private POIFSMiniStore _mini_store | |
| _property_table | back to summary |
|---|---|
| private PropertyTable _property_table | |
| _root | back to summary |
|---|---|
| private DirectoryNode _root | |
| _xbat_blocks | back to summary |
|---|---|
| private final List<BATBlock> _xbat_blocks | |
| bigBlockSize | back to summary |
|---|---|
| private POIFSBigBlockSize bigBlockSize What big block size the file uses. Most files use 512 bytes, but a few use 4096 | |
| DEFAULT_MAX_RECORD_LENGTH | back to summary |
|---|---|
| private static final int DEFAULT_MAX_RECORD_LENGTH | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| MAX_ALLOCATION_SIZE | back to summary |
|---|---|
| private static final int MAX_ALLOCATION_SIZE | |
| MAX_BLOCK_COUNT | back to summary |
|---|---|
| private static final int MAX_BLOCK_COUNT Maximum number size (in blocks) of the allocation table as supported by POI.
This constant has been chosen to help POI identify corrupted data in the
header block (rather than crash immediately with | |
| MAX_RECORD_LENGTH | back to summary |
|---|---|
| private static int MAX_RECORD_LENGTH | |
| POIFSFileSystem | back to summary |
|---|---|
| private POIFSFileSystem(boolean newFS) | |
| POIFSFileSystem | back to summary |
|---|---|
| public POIFSFileSystem() Constructor, intended for writing | |
| POIFSFileSystem | back to summary |
|---|---|
| public POIFSFileSystem(File file) throws IOException Creates a POIFSFileSystem from a Note that with this constructor, you will need to call
| |
| POIFSFileSystem | back to summary |
|---|---|
| public POIFSFileSystem(File file, boolean readOnly) throws IOException Creates a POIFSFileSystem from a Note that with this constructor, you will need to call
| |
| POIFSFileSystem | back to summary |
|---|---|
| public POIFSFileSystem(FileChannel channel) throws IOException Creates a POIFSFileSystem from an open Note that with this constructor, you will need to call
| |
| POIFSFileSystem | back to summary |
|---|---|
| public POIFSFileSystem(FileChannel channel, boolean readOnly) throws IOException Creates a POIFSFileSystem from an open Note that with this constructor, you will need to call
| |
| POIFSFileSystem | back to summary |
|---|---|
| public POIFSFileSystem(FileChannel channel, boolean readOnly, boolean closeChannel) throws IOException Creates a POIFSFileSystem from an open Note that with this constructor, you will need to call
| |
| POIFSFileSystem | back to summary |
|---|---|
private POIFSFileSystem(FileChannel channel, File srcFile, boolean readOnly, boolean closeChannelOnError, boolean closeChannelOnClose) throws IOException
| |
| POIFSFileSystem | back to summary |
|---|---|
| public POIFSFileSystem(InputStream stream) throws IOException Create a POIFSFileSystem from an
Some streams are usable after reaching EOF (typically those that return 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);
| |
| _get_property_table | back to summary |
|---|---|
| pack-priv PropertyTable _get_property_table() For unit testing only! Returns the underlying properties table | |
| addDirectory | back to summary |
|---|---|
| pack-priv void addDirectory(final DirectoryProperty directory) add a new DirectoryProperty to the FileSystem
| |
| addDocument | back to summary |
|---|---|
| pack-priv void addDocument(final POIFSDocument document) add a new POIFSDocument to the FileSytem
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Implements java. Closes the FileSystem, freeing any underlying files, streams and buffers. After this, you will be unable to read or write from the FileSystem.
| |
| closeInputStream | back to summary |
|---|---|
private void closeInputStream(InputStream stream, boolean success)
| |
| create | back to summary |
|---|---|
| public static POIFSFileSystem create(File file) throws IOException Creates a new POIFSFileSystem in a new
| |
| createBAT | back to summary |
|---|---|
| private BATBlock createBAT(int offset, boolean isBAT) throws IOException | |
| createBlockIfNeeded | back to summary |
|---|---|
| protected ByteBuffer createBlockIfNeeded(final int offset) throws IOException Implements abstract org. Load the block at the given offset, extending the file if needed
| |
| createDirectory | back to summary |
|---|---|
| public DirectoryEntry createDirectory(final String name) throws IOException create a new DirectoryEntry in the root directory
| |
| createDocument | back to summary |
|---|---|
| public DocumentEntry createDocument(final InputStream stream, final String name) throws IOException Create a new document to be added to the root directory
| |
| createDocument | back to summary |
|---|---|
| public DocumentEntry createDocument(final String name, final int size, final POIFSWriterListener writer) throws IOException create a new DocumentEntry in the root entry; the data will be provided later
| |
| createDocumentInputStream | back to summary |
|---|---|
| public DocumentInputStream createDocumentInputStream(final String documentName) throws IOException open a document in the root entry's list of entries
| |
| createNewDataSource | back to summary |
|---|---|
| protected void createNewDataSource() | |
| createOrUpdateDocument | back to summary |
|---|---|
| public DocumentEntry createOrUpdateDocument(final InputStream stream, final String name) throws IOException Set the contents of a document in the root directory, creating if needed, otherwise updating
| |
| getBATBlockAndIndex | back to summary |
|---|---|
| protected BATBlock. Implements abstract org. Returns the BATBlock that handles the specified offset, and the relative index within it
| |
| getBigBlockSize | back to summary |
|---|---|
public int getBigBlockSize()
| |
| getBigBlockSizeDetails | back to summary |
|---|---|
public POIFSBigBlockSize getBigBlockSizeDetails()
| |
| getBlockAt | back to summary |
|---|---|
| protected ByteBuffer getBlockAt(final int offset) throws IOException Implements abstract org. Load the block at the given offset.
| |
| getBlockStoreBlockSize | back to summary |
|---|---|
| protected int getBlockStoreBlockSize() Implements abstract org. Doc from org. Returns the size of the blocks managed through the block store.
| |
| getChainLoopDetector | back to summary |
|---|---|
| protected BlockStore. Implements abstract org. Doc from org. Creates a Detector for loops in the chain
| |
| getFreeBlock | back to summary |
|---|---|
| protected int getFreeBlock() throws IOException Implements abstract org. Finds a free block, and returns its offset. This method will extend the file if needed, and if doing so, allocate new FAT blocks to address the extra space.
| |
| getHeaderBlock | back to summary |
|---|---|
public HeaderBlock getHeaderBlock()
| |
| getMaxRecordLength | back to summary |
|---|---|
public static int getMaxRecordLength()
| |
| getMiniStore | back to summary |
|---|---|
| pack-priv POIFSMiniStore getMiniStore() Returns the MiniStore, which performs a similar low level function to this, except for the small blocks. | |
| getNextBlock | back to summary |
|---|---|
| protected int getNextBlock(final int offset) Implements abstract org. Works out what block follows the specified one.
| |
| getPropertyTable | back to summary |
|---|---|
public PropertyTable getPropertyTable()
| |
| getRoot | back to summary |
|---|---|
| public DirectoryNode getRoot() Get the root entry
| |
| getShortDescription | back to summary |
|---|---|
| public String getShortDescription() Implements org. Provides a short description of the object, to be used when a POIFSViewable object has not provided its contents. | |
| getViewableArray | back to summary |
|---|---|
| public Object[] getViewableArray() Implements org. Get an array of objects, some of which may implement POIFSViewable | |
| getViewableIterator | back to summary |
|---|---|
| public Iterator Implements org. Get an Iterator of objects, some of which may implement POIFSViewable | |
| isInPlaceWriteable | back to summary |
|---|---|
| public boolean isInPlaceWriteable() Does the filesystem support an in-place write via
| |
| main | back to summary |
|---|---|
| public static void main(String[] args) throws IOException read in a file and write it back out again
| |
| preferArray | back to summary |
|---|---|
| public boolean preferArray() Implements org. Give viewers a hint as to whether to call getViewableArray or getViewableIterator
| |
| readBAT | back to summary |
|---|---|
| private void readBAT(int batAt, BlockStore. | |
| readCoreContents | back to summary |
|---|---|
| private void readCoreContents() throws IOException Read and process the PropertiesTable and the FAT / XFAT blocks, so that we're ready to work with the file | |
| releaseBuffer | back to summary |
|---|---|
| protected void releaseBuffer(ByteBuffer buffer) Implements abstract org. Doc from org. Releases a mmap-ed buffer, which you are sure won't be used again
| |
| remove | back to summary |
|---|---|
| pack-priv void remove(EntryNode entry) throws IOException remove an entry
| |
| sanityCheckBlockCount | back to summary |
|---|---|
| private static void sanityCheckBlockCount(int block_count) throws IOException | |
| setMaxRecordLength | back to summary |
|---|---|
public static void setMaxRecordLength(int length)
| |
| setNextBlock | back to summary |
|---|---|
| protected void setNextBlock(final int offset, final int nextBlock) Implements abstract org. Changes the record of what block follows the specified one.
| |
| size | back to summary |
|---|---|
| protected long size() throws IOException | |
| syncWithDataSource | back to summary |
|---|---|
| private void syncWithDataSource() throws IOException Has our in-memory objects write their state to their backing blocks | |
| writeFilesystem | back to summary |
|---|---|
| public void writeFilesystem() throws IOException Write the filesystem out to the open file. Will thrown an
| |
| writeFilesystem | back to summary |
|---|---|
| public void writeFilesystem(final OutputStream stream) throws IOException Write the filesystem out
| |