Class NPOIFSStream
java.lang.Object
org.docx4j.org.apache.poi.poifs.filesystem.NPOIFSStream
- All Implemented Interfaces:
Iterable<ByteBuffer>
This handles reading and writing a stream within a
NPOIFSFileSystem. It can supply an iterator
to read blocks, and way to write out to existing and
new blocks.
Most users will want a higher level version of this,
which deals with properties to track which stream
this is.
This only works on big block streams, it doesn't
handle small block ones.
This uses the new NIO code
TODO Implement a streaming write method, and append-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classprotected classClass that handles a streaming read of one stream -
Constructor Summary
ConstructorsConstructorDescriptionNPOIFSStream(BlockStore blockStore) Constructor for a new stream.NPOIFSStream(BlockStore blockStore, int startBlock) Constructor for an existing stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidfree()Frees all blocks in the streamintWhat block does this stream start at? Will bePOIFSConstants.END_OF_CHAINfor a new stream that hasn't been written to yet.iterator()Returns an iterator that'll supply oneByteBufferper block in the stream.voidupdateContents(byte[] contents) Updates the contents of the stream to the new set of bytes.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
NPOIFSStream
Constructor for an existing stream. It's up to you to know how to get the start block (eg from aHeaderBlockor aProperty) -
NPOIFSStream
Constructor for a new stream. A start block won't be allocated until you begin writing to it.
-
-
Method Details
-
getStartBlock
public int getStartBlock()What block does this stream start at? Will bePOIFSConstants.END_OF_CHAINfor a new stream that hasn't been written to yet. -
iterator
Returns an iterator that'll supply oneByteBufferper block in the stream.- Specified by:
iteratorin interfaceIterable<ByteBuffer>
-
getBlockIterator
-
updateContents
Updates the contents of the stream to the new set of bytes. Note - if this is property based, you'll still need to update the size in the property yourself- Throws:
IOException
-
getOutputStream
- Throws:
IOException
-
free
Frees all blocks in the stream- Throws:
IOException
-