Class ZipUtils

java.lang.Object
gov.niem.tools.api.core.utils.ZipUtils

public class ZipUtils extends Object
Zipfile-related utility functions.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Path
    unzip(Path zipPath)
    Unzips the zip file at the given path to a temporary folder.
    static Path
    unzip(Path zipPath, Path outputDir)
    Unzips the zip file at the given path to a temporary folder.
    static void
    zip(File sourceDir, String zipFilePathString)
    Zips the contents of the given source directory to the specified path.
    static net.lingala.zip4j.ZipFile
    zip(String zipFilePathString, List<File> files)
    Adds a file to the given zip file.
    static byte[]
    zip(List<File> files)
    Returns a byte array for a zipfile of the given list of files.

    Methods inherited from class java.lang.Object

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

    • ZipUtils

      public ZipUtils()
  • Method Details

    • zip

      public static byte[] zip(List<File> files) throws Exception
      Returns a byte array for a zipfile of the given list of files.
      Throws:
      Exception
    • zip

      public static void zip(File sourceDir, String zipFilePathString) throws net.lingala.zip4j.exception.ZipException, IOException
      Zips the contents of the given source directory to the specified path.
      Throws:
      net.lingala.zip4j.exception.ZipException
      IOException
    • zip

      public static net.lingala.zip4j.ZipFile zip(String zipFilePathString, List<File> files) throws net.lingala.zip4j.exception.ZipException, IOException
      Adds a file to the given zip file.
      Throws:
      net.lingala.zip4j.exception.ZipException
      IOException
    • unzip

      public static Path unzip(Path zipPath) throws IOException
      Unzips the zip file at the given path to a temporary folder.
      Returns:
      - Path to the temporary folder where the files have been extracted.
      Throws:
      IOException
    • unzip

      public static Path unzip(Path zipPath, Path outputDir) throws IOException
      Unzips the zip file at the given path to a temporary folder.
      Returns:
      - Path to the temporary folder where the files have been extracted.
      Throws:
      IOException