Class SevenZArchiveReader.Builder

Enclosing class:
SevenZArchiveReader

public static class SevenZArchiveReader.Builder extends ArchiveReaderBuilder<SevenZArchiveReader,SevenZArchiveReader.Builder>
Builds new instances of SevenZArchiveReader.
Since:
1.26.0
  • Field Details

    • password

      private byte[] password
    • maxMemoryLimitKb

      private int maxMemoryLimitKb
    • useDefaultNameForUnnamedEntries

      private boolean useDefaultNameForUnnamedEntries
    • tryToRecoverBrokenArchives

      private boolean tryToRecoverBrokenArchives
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • get

      public SevenZArchiveReader get() throws IOException
      Description copied from class: ArchiveReaderBuilder
      Gets the archive reader.
      Specified by:
      get in class ArchiveReaderBuilder<SevenZArchiveReader,SevenZArchiveReader.Builder>
      Returns:
      a result.
      Throws:
      IOException - if an I/O error occurs.
    • setDefaultName

      public SevenZArchiveReader.Builder setDefaultName(String defaultName)
      Sets the default name.
      Parameters:
      defaultName - the default name.
      Returns:
      this instance.
      See Also:
    • setMaxMemoryLimitKb

      public SevenZArchiveReader.Builder setMaxMemoryLimitKb(int maxMemoryLimitKb)
      Sets the maximum amount of memory in kilobytes to use for parsing the archive and during extraction.

      Not all codecs honor this setting. Currently only LZMA and LZMA2 are supported.

      Parameters:
      maxMemoryLimitKb - the max memory limit in kilobytes.
      Returns:
      this instance.
    • setPassword

      public SevenZArchiveReader.Builder setPassword(byte[] password)
      Sets the password.
      Parameters:
      password - the password.
      Returns:
      this instance.
    • setPassword

      public SevenZArchiveReader.Builder setPassword(char[] password)
      Sets the password.
      Parameters:
      password - the password.
      Returns:
      this instance.
    • setPassword

      public SevenZArchiveReader.Builder setPassword(String password)
      Sets the password.
      Parameters:
      password - the password.
      Returns:
      this instance.
    • setTryToRecoverBrokenArchives

      public SevenZArchiveReader.Builder setTryToRecoverBrokenArchives(boolean tryToRecoverBrokenArchives)
      Sets whether SevenZArchiveReader will try to recover broken archives where the CRC of the file's metadata is 0.

      This special kind of broken archive is encountered when mutli volume archives are closed prematurely. If you enable this option SevenZFile will trust data that looks as if it could contain metadata of an archive and allocate big amounts of memory. It is strongly recommended to not enable this option without setting setMaxMemoryLimitKb(int) at the same time.

      Parameters:
      tryToRecoverBrokenArchives - whether SevenZArchiveReader will try to recover broken archives where the CRC of the file's metadata is 0.
      Returns:
      this instance.
    • setUseDefaultNameForUnnamedEntries

      public SevenZArchiveReader.Builder setUseDefaultNameForUnnamedEntries(boolean useDefaultNameForUnnamedEntries)
      Sets whether entries without a name should get their names set to the archive's default file name.
      Parameters:
      useDefaultNameForUnnamedEntries - whether entries without a name should get their names set to the archive's default file name.
      Returns:
      this instance.