Package org.apache.commons.compress.archivers.zip

# Class ZipFile.Builder

java.lang.Object
org.apache.commons.io.build.AbstractSupplier<ZipFile,ZipFile.Builder>
org.apache.commons.io.build.AbstractOriginSupplier<ZipFile,ZipFile.Builder>
org.apache.commons.io.build.AbstractStreamBuilder<ZipFile,ZipFile.Builder>
org.apache.commons.compress.archivers.zip.ZipFile.Builder

All Implemented Interfaces:
  `IOSupplier<ZipFile>`

Enclosing class:
  `ZipFile`

public static class ZipFile.Builder extends AbstractStreamBuilder<ZipFile,ZipFile.Builder>
Builds new `ZipFile` instances.

The channel will be opened for reading, assuming the specified encoding for file names.

See `SeekableInMemoryByteChannel` to read from an in-memory archive.

By default the central directory record and all local file headers of the archive will be read immediately which may take a considerable amount of time when the archive is big. The `ignoreLocalFileHeader` parameter can be set to `true` which restricts parsing to the central directory. Unfortunately the local file header may contain information not present inside of the central directory which will not be available when the argument is set to `true`. This includes the content of the Unicode extra field, so setting `ignoreLocalFileHeader` to `true` means `useUnicodeExtraFields` will be ignored effectively.

Since:
  1.26.0

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Builder()`
  Constructs a new instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ZipFile`
  `get()`
  `ZipFile.Builder`
  `setIgnoreLocalFileHeader(boolean ignoreLocalFileHeader)`
  Sets whether to ignore information stored inside the local file header.
  `ZipFile.Builder`
  `setMaxNumberOfDisks(long maxNumberOfDisks)`
  Sets max number of multi archive disks, default is 1 (no multi archive).
  `ZipFile.Builder`
  `setSeekableByteChannel(SeekableByteChannel seekableByteChannel)`
  The actual channel, overrides any other input aspects like a File, Path, and so on.
  `ZipFile.Builder`
  `setUseUnicodeExtraFields(boolean useUnicodeExtraFields)`
  Sets whether to use InfoZIP Unicode Extra Fields (if present) to set the file names.
  `ZipFile.Builder`
  `setZstdInputStreamFactory(IOFunction<InputStream,InputStream> zstdInpStreamFactory)`
  Sets the factory `IOFunction` to create a Zstd `InputStream`.

  ### Methods inherited from class org.apache.commons.io.build.AbstractStreamBuilder

  `getBufferSize, getBufferSizeDefault, getCharSequence, getCharset, getCharsetDefault, getFile, getInputStream, getOpenOptions, getOutputStream, getPath, getRandomAccessFile, getReader, getWriter, setBufferSize, setBufferSize, setBufferSizeChecker, setBufferSizeDefault, setBufferSizeMax, setCharset, setCharset, setCharsetDefault, setOpenOptions`

  ### Methods inherited from class org.apache.commons.io.build.AbstractOriginSupplier

  `checkOrigin, getOrigin, hasOrigin, newByteArrayOrigin, newCharSequenceOrigin, newFileOrigin, newFileOrigin, newInputStreamOrigin, newOutputStreamOrigin, newPathOrigin, newPathOrigin, newRandomAccessFileOrigin, newRandomAccessFileOrigin, newReaderOrigin, newURIOrigin, newWriterOrigin, setByteArray, setCharSequence, setFile, setFile, setInputStream, setOrigin, setOutputStream, setPath, setPath, setRandomAccessFile, setRandomAccessFile, setReader, setURI, setWriter`

  ### Methods inherited from class org.apache.commons.io.build.AbstractSupplier

  `asThis`

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

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

  ### Methods inherited from interface org.apache.commons.io.function.IOSupplier

  `asSupplier, getUnchecked`

- ## Constructor Details

  - ### Builder

    public Builder()
    Constructs a new instance.

- ## Method Details

  - ### get

    public ZipFile get() throws IOException
    Throws:
      `IOException`

  - ### setIgnoreLocalFileHeader

    public ZipFile.Builder setIgnoreLocalFileHeader(boolean ignoreLocalFileHeader)
    Sets whether to ignore information stored inside the local file header.
    Parameters:
      `ignoreLocalFileHeader` - whether to ignore information stored inside.
    Returns:
      `this` instance.

  - ### setMaxNumberOfDisks

    public ZipFile.Builder setMaxNumberOfDisks(long maxNumberOfDisks)
    Sets max number of multi archive disks, default is 1 (no multi archive).
    Parameters:
      `maxNumberOfDisks` - max number of multi archive disks.
    Returns:
      `this` instance.

  - ### setSeekableByteChannel

    public ZipFile.Builder setSeekableByteChannel(SeekableByteChannel seekableByteChannel)
    The actual channel, overrides any other input aspects like a File, Path, and so on.
    Parameters:
      `seekableByteChannel` - The actual channel.
    Returns:
      `this` instance.

  - ### setUseUnicodeExtraFields

    public ZipFile.Builder setUseUnicodeExtraFields(boolean useUnicodeExtraFields)
    Sets whether to use InfoZIP Unicode Extra Fields (if present) to set the file names.
    Parameters:
      `useUnicodeExtraFields` - whether to use InfoZIP Unicode Extra Fields (if present) to set the file names.
    Returns:
      `this` instance.

  - ### setZstdInputStreamFactory

    public ZipFile.Builder setZstdInputStreamFactory(IOFunction<InputStream,InputStream> zstdInpStreamFactory)
    Sets the factory `IOFunction` to create a Zstd `InputStream`. Defaults to `ZstdCompressorInputStream(InputStream)`.

    Call this method to plugin an alternate Zstd input stream implementation.

    Parameters:
      `zstdInpStreamFactory` - the factory `IOFunction` to create a Zstd `InputStream`; `null` resets to the default.
    Returns:
      `this` instance.
    Since:
      1.28.0