java.lang.Object
io.github.astrapi69.zip.UnZipper

public class UnZipper extends Object
The `UnZipper` class provides methods to extract zip entries to a specified directory. It utilizes `ZipExtensions` for performing the extraction operations.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Builder class for constructing `Unzipper` objects.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
    UnZipper(File toDir, ZipFile zipFile)
    Constructs an `Unzipper` with the given target directory and zip file.
    UnZipper(ZipFile zipFile, File toDir)
    Constructs an `Unzipper` with the given zip file and target directory.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a builder for constructing `Unzipper` objects.
    void
    extractZipEntry(ZipFile zipFile, ZipEntry target, File toDirectory)
    Extracts a specific zip entry to the target directory.
    Retrieves the current target directory for extraction.
    Retrieves the current zip file being used for extraction.
    void
    setToDir(File toDir)
    Sets the target directory for extraction.
    void
    Sets the zip file to use for extraction.
    Creates a builder initialized with the current `Unzipper` instance's properties.
    Returns a string representation of the `Unzipper` object, showing its current target directory and zip file.
    void
    Extracts all entries from the current zip file to the current target directory.
    void
    unzip(ZipFile zipFile, File toDir)
    Extracts all entries from the specified zip file to the specified target directory.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • UnZipper

      public UnZipper()
      Default constructor.
    • UnZipper

      public UnZipper(File toDir, ZipFile zipFile)
      Constructs an `Unzipper` with the given target directory and zip file.
      Parameters:
      toDir - the directory to extract files to
      zipFile - the zip file to extract entries from
    • UnZipper

      public UnZipper(ZipFile zipFile, File toDir)
      Constructs an `Unzipper` with the given zip file and target directory.
      Parameters:
      zipFile - the zip file to extract entries from
      toDir - the directory to extract files to
  • Method Details

    • builder

      public static UnZipper.UnzipperBuilder builder()
      Creates a builder for constructing `Unzipper` objects.
      Returns:
      a new `UnzipperBuilder` instance
    • extractZipEntry

      public void extractZipEntry(ZipFile zipFile, ZipEntry target, File toDirectory) throws IOException
      Extracts a specific zip entry to the target directory.
      Parameters:
      zipFile - the zip file containing the entry
      target - the zip entry to extract
      toDirectory - the directory to extract the entry to
      Throws:
      IOException - if an I/O error occurs during extraction
    • getToDir

      public File getToDir()
      Retrieves the current target directory for extraction.
      Returns:
      the current target directory
    • setToDir

      public void setToDir(File toDir)
      Sets the target directory for extraction.
      Parameters:
      toDir - the directory to set as the target for extraction
    • getZipFile

      public ZipFile getZipFile()
      Retrieves the current zip file being used for extraction.
      Returns:
      the current zip file
    • setZipFile

      public void setZipFile(ZipFile zipFile)
      Sets the zip file to use for extraction.
      Parameters:
      zipFile - the zip file to set for extraction
    • toBuilder

      public UnZipper.UnzipperBuilder toBuilder()
      Creates a builder initialized with the current `Unzipper` instance's properties.
      Returns:
      a new `UnzipperBuilder` initialized with the current instance's properties
    • toString

      public String toString()
      Returns a string representation of the `Unzipper` object, showing its current target directory and zip file.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the `Unzipper` object
    • unzip

      public void unzip() throws IOException
      Extracts all entries from the current zip file to the current target directory.
      Throws:
      IOException - if an I/O error occurs during extraction
    • unzip

      public void unzip(ZipFile zipFile, File toDir) throws IOException
      Extracts all entries from the specified zip file to the specified target directory.
      Parameters:
      zipFile - the zip file to extract entries from
      toDir - the directory to extract entries to
      Throws:
      IOException - if an I/O error occurs during extraction