Package com.independentsoft.io.structuredstorage

# Class CompoundFile

java.lang.Object
com.independentsoft.io.structuredstorage.CompoundFile

public class CompoundFile extends Object
Represents a file used to store data as virtual streams.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CompoundFile()`
  Initializes a new instance of the CompoundFile class.
  `CompoundFile​(InputStream stream)`
  Initializes a new instance of the CompoundFile class from the stream.
  `CompoundFile​(String filePath)`
  Initializes a new instance of the CompoundFile class from the file.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `byte[]`
  `getClassId()`
  Gets compound file class ID.
  `int`
  `getFatSectorCount()`
  Gets FAT sector count.
  `InputStream`
  `getInputStream()`
  Gets stream to read from this compound file.
  `short`
  `getMajorVersion()`
  Gets major version.
  `long`
  `getMiniFatSectorCount()`
  Gets count of mini FAT sectors.
  `short`
  `getMiniSectorSize()`
  Gets size of mini sectors.
  `long`
  `getMiniStreamMaxSize()`
  Gets maximum size of mini streams.
  `RootDirectoryEntry`
  `getRoot()`
  Gets the root node.
  `short`
  `getSectorSize()`
  Gets FAT sector size.
  `void`
  `open​(InputStream inputStream)`
  Opens compound file from the specified stream.
  `void`
  `open​(String filePath)`
  Opens compound file from the specified file.
  `void`
  `save​(OutputStream outputStream)`
  Saves this compound file to the specified stream.
  `void`
  `save​(String filePath)`
  Saves this compound file to the specified file.
  `void`
  `save​(String filePath, boolean overwrite)`
  Saves this compound file to the specified file.
  `void`
  `setClassId​(byte[] classId)`
  Sets compound file class ID.
  `void`
  `setMajorVersion​(short majorVersion)`
  Sets major version.
  `byte[]`
  `toByteArray()`
  Gets buffer to read from this compound file.

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

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

- ## Constructor Details

  - ### CompoundFile

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

  - ### CompoundFile

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

  - ### CompoundFile

    public CompoundFile​(InputStream stream) throws IOException
    Initializes a new instance of the CompoundFile class from the stream.
    Parameters:
      `stream` - the stream
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

- ## Method Details

  - ### open

    public void open​(String filePath) throws IOException
    Opens compound file from the specified file.
    Parameters:
      `filePath` - the file path
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### open

    public void open​(InputStream inputStream) throws IOException
    Opens compound file from the specified stream.
    Parameters:
      `inputStream` - the input stream
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getInputStream

    public InputStream getInputStream() throws IOException
    Gets stream to read from this compound file.
    Returns:
      the input stream
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### toByteArray

    public byte[] toByteArray() throws IOException
    Gets buffer to read from this compound file.
    Returns:
      the byte[]
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### save

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

  - ### save

    public void save​(String filePath, boolean overwrite) throws IOException
    Saves this compound file to the specified file.
    Parameters:
      `filePath` - File path.
      `overwrite` - if true overwrites existing file with the same file path.
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### save

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

  - ### getRoot

    public RootDirectoryEntry getRoot()
    Gets the root node.
    Returns:
      the root

  - ### getMajorVersion

    public short getMajorVersion()
    Gets major version. Allowed values are 3 (512 bytes sector size) or 4 (4096 bytes sector size).
    Returns:
      the major version

  - ### setMajorVersion

    public void setMajorVersion​(short majorVersion)
    Sets major version. Allowed values are 3 (512 bytes sector size) or 4 (4096 bytes sector size).
    Parameters:
      `majorVersion` - the new major version

  - ### getSectorSize

    public short getSectorSize()
    Gets FAT sector size.
    Returns:
      the sector size

  - ### getMiniSectorSize

    public short getMiniSectorSize()
    Gets size of mini sectors.
    Returns:
      the mini sector size

  - ### getFatSectorCount

    public int getFatSectorCount()
    Gets FAT sector count.
    Returns:
      the fat sector count

  - ### getMiniStreamMaxSize

    public long getMiniStreamMaxSize()
    Gets maximum size of mini streams.
    Returns:
      the mini stream max size

  - ### getMiniFatSectorCount

    public long getMiniFatSectorCount()
    Gets count of mini FAT sectors.
    Returns:
      the mini fat sector count

  - ### getClassId

    public byte[] getClassId()
    Gets compound file class ID.
    Returns:
      the class id

  - ### setClassId

    public void setClassId​(byte[] classId)
    Sets compound file class ID.
    Parameters:
      `classId` - the new class id