Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.poi.poifs.filesystem
Class NPOIFSStream

    java.lang.Object
      org.apache.poi.poifs.filesystem.NPOIFSStream

All Implemented Interfaces:
  java.lang.Iterable<java.nio.ByteBuffer>

    public class NPOIFSStream

extends java.lang.Object
implements java.lang.Iterable<java.nio.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
`protected class` | `NPOIFSStream.StreamBlockByteBuffer`
`protected class` | `NPOIFSStream.StreamBlockByteBufferIterator` Class that handles a streaming read of one stream

Constructor Summary
`NPOIFSStream(BlockStore blockStore)` Constructor for a new stream.
`NPOIFSStream(BlockStore blockStore, int startBlock)` Constructor for an existing stream.

Method Summary
`void` | `free()` Frees all blocks in the stream
`java.util.Iterator<java.nio.ByteBuffer>` | `getBlockIterator()`
`java.io.OutputStream` | `getOutputStream()`
`int` | `getStartBlock()` What block does this stream start at? Will be `POIFSConstants.END_OF_CHAIN` for a new stream that hasn't been written to yet.
`java.util.Iterator<java.nio.ByteBuffer>` | `iterator()` Returns an iterator that'll supply one `ByteBuffer` per block in the stream.
`void` | `updateContents(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, wait`

Constructor Detail

### NPOIFSStream

    public NPOIFSStream(BlockStore blockStore,
                        int startBlock)

  Constructor for an existing stream. It's up to you to know how to get the start block (eg from a `HeaderBlock` or a `Property`)

### NPOIFSStream

    public NPOIFSStream(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 be `POIFSConstants.END_OF_CHAIN` for a new stream that hasn't been written to yet.

### iterator

    public java.util.Iterator<java.nio.ByteBuffer> iterator()

  Returns an iterator that'll supply one `ByteBuffer` per block in the stream.

  Specified by:
    `iterator` in interface `java.lang.Iterable<java.nio.ByteBuffer>`

### getBlockIterator

    public java.util.Iterator<java.nio.ByteBuffer> getBlockIterator()

### updateContents

    public void updateContents(byte[] contents)
                        throws java.io.IOException

  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:
    `java.io.IOException`

### getOutputStream

    public java.io.OutputStream getOutputStream()
                                         throws java.io.IOException

  Throws:
    `java.io.IOException`

### free

    public void free()
              throws java.io.IOException

  Frees all blocks in the stream

  Throws:
    `java.io.IOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2017 The Apache Software Foundation or its licensors, as applicable.