Package com.independentsoft.io.structuredstorage

# Class Stream

java.lang.Object
com.independentsoft.io.structuredstorage.DirectoryEntry
com.independentsoft.io.structuredstorage.Stream

All Implemented Interfaces:
  `Comparable<DirectoryEntry>`

public class Stream extends DirectoryEntry
Represents a virtual stream to store data. Stream is analogous to a file system file. The parent object of a stream object must be a Storage object or the RootDirectoryEntry.

- ## Field Summary

  ### Fields inherited from class com.independentsoft.io.structuredstorage.DirectoryEntry

  `buffer, childSid, classId, color, createdTime, directoryEntries, lastModifiedTime, leftSiblingSid, name, parent, PROPERTY_TYPE, rightSiblingSid, size, startSector, type, userFlags`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Stream()`
  Initializes a new instance of the Stream class.
  `Stream​(String filePath)`
  Initializes a new instance of the Stream class and load data from the specified file.
  `Stream​(String name, byte[] buffer)`
  Initializes a new instance of the Stream class and load data from the specified buffer.
  `Stream​(String name, InputStream stream)`
  Initializes a new instance of the Stream class and load data from the specified System.IO.Stream.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `byte[]`
  `getBuffer()`
  Gets streams data.
  `InputStream`
  `getInputStream()`
  Gets InputStream to read data from this stream.
  `void`
  `load​(String filePath)`
  Loads data to this stream from the specified file.
  `void`
  `load​(String name, byte[] buffer)`
  Loads data to this stream from the specified buffer.
  `void`
  `load​(String name, InputStream inputStream)`
  Loads data to this stream from the specified InputStream.
  `void`
  `save​(OutputStream stream)`
  Saves data from this stream to the specified stream.
  `void`
  `save​(String filePath)`
  Saves data from this stream to to the specified file.
  `void`
  `setBuffer​(byte[] buffer)`
  Sets streams data.

  ### Methods inherited from class com.independentsoft.io.structuredstorage.DirectoryEntry

  `compareTo, getClassId, getCreatedTime, getLastModifiedTime, getName, getSize, setClassId, setName`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Stream

    public Stream()
    Initializes a new instance of the Stream class.

  - ### Stream

    public Stream​(String filePath) throws IOException
    Initializes a new instance of the Stream class and load data from the specified file.
    Parameters:
      `filePath` - the file path
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### Stream

    public Stream​(String name, InputStream stream) throws IOException
    Initializes a new instance of the Stream class and load data from the specified System.IO.Stream.
    Parameters:
      `name` - the name
      `stream` - the stream
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### Stream

    public Stream​(String name, byte[] buffer)
    Initializes a new instance of the Stream class and load data from the specified buffer.
    Parameters:
      `name` - the name
      `buffer` - the buffer

- ## Method Details

  - ### load

    public void load​(String filePath) throws IOException
    Loads data to this stream from the specified file.
    Parameters:
      `filePath` - the file path
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### load

    public void load​(String name, InputStream inputStream) throws IOException
    Loads data to this stream from the specified InputStream.
    Parameters:
      `name` - the name
      `inputStream` - the input stream
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### load

    public void load​(String name, byte[] buffer)
    Loads data to this stream from the specified buffer.
    Parameters:
      `name` - the name
      `buffer` - the buffer

  - ### save

    public void save​(String filePath) throws IOException
    Saves data from this stream to to the specified file.
    Parameters:
      `filePath` - the file path
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### save

    public void save​(OutputStream stream) throws IOException
    Saves data from this stream to the specified stream.
    Parameters:
      `stream` - the stream
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getInputStream

    public InputStream getInputStream()
    Gets InputStream to read data from this stream.
    Returns:
      the input stream

  - ### getBuffer

    public byte[] getBuffer()
    Gets streams data.
    Returns:
      the buffer

  - ### setBuffer

    public void setBuffer​(byte[] buffer)
    Sets streams data.
    Parameters:
      `buffer` - the new buffer