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 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