Package org.apache.poi.poifs.filesystem
Class POIFSStream
- java.lang.Object
-
- org.apache.poi.poifs.filesystem.POIFSStream
-
- All Implemented Interfaces:
Iterable<ByteBuffer>
public class POIFSStream extends Object implements Iterable<ByteBuffer>
This handles reading and writing a stream within aPOIFSFileSystem
. 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 Classes Modifier and Type Class Description protected class
POIFSStream.StreamBlockByteBuffer
-
Constructor Summary
Constructors Constructor Description POIFSStream(BlockStore blockStore)
Constructor for a new stream.POIFSStream(BlockStore blockStore, int startBlock)
Constructor for an existing stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
free()
Frees all blocks in the streamOutputStream
getOutputStream()
int
getStartBlock()
What block does this stream start at? Will bePOIFSConstants.END_OF_CHAIN
for a new stream that hasn't been written to yet.Iterator<ByteBuffer>
iterator()
Returns an iterator that'll supply oneByteBuffer
per block in the stream.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
POIFSStream
public POIFSStream(BlockStore blockStore, int startBlock)
Constructor for an existing stream. It's up to you to know how to get the start block (eg from aHeaderBlock
or aProperty
)
-
POIFSStream
public POIFSStream(BlockStore blockStore)
Constructor for a new stream. A start block won't be allocated until you begin writing to it.
-
-
Method Detail
-
getStartBlock
public int getStartBlock()
What block does this stream start at? Will bePOIFSConstants.END_OF_CHAIN
for a new stream that hasn't been written to yet.
-
iterator
public Iterator<ByteBuffer> iterator()
Returns an iterator that'll supply oneByteBuffer
per block in the stream.- Specified by:
iterator
in interfaceIterable<ByteBuffer>
-
getOutputStream
public OutputStream getOutputStream() throws IOException
- Throws:
IOException
-
free
public void free() throws IOException
Frees all blocks in the stream- Throws:
IOException
-
-