com.jscape.zip

## Class Zip

- java.lang.Object
- - com.jscape.zip.Zip

- All Implemented Interfaces:
    Archive

      public class Zip
      extends java.lang.Object
      implements Archive

  Implements the basic functionality of ZIP compression and decompression.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static char` | `BACK_SLASH`
    `static int` | `BUF_SIZE`
    `static char` | `FORWARD_SLASH`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Zip()` Creates a new Zip instance.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addArchiveListener(ArchiveListener listener)` Adds listener.
    `void` | `compress(java.io.File file)` Creates a new ZIP archive.
    `void` | `compress(java.io.File file, java.io.File targetPath)` Creates a new ZIP archive.
    `void` | `compress(java.io.File output, java.util.Vector sourceVector)` Expects a Vector of files and zips the content to the output file
    `void` | `decompress(java.io.File file)` Decompress all the files in given ZIP archive.
    `void` | `decompress(java.io.File file, java.io.File output)` Decompress all the files in given ZIP archive.
    `static java.util.Vector` | `getList(java.lang.String sDir)` Recursively calculates the list of files.
    `long` | `getSize(java.util.Vector files)` Get size of files in Vector
    `void` | `interrupt()` Interrupt this instance & stop any ongoing compression / decompression.
    `boolean` | `isInterrupted()` Returns whether this instance has been interrupted.
    `void` | `removeArchiveListener(ArchiveListener listener)` Removes listener.
    `void` | `reset()` Reset the interrupted flag.

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

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

- - ### Field Detail

    - #### FORWARD_SLASH

          public static final char FORWARD_SLASH

      See Also:
        Constant Field Values

    - #### BACK_SLASH

          public static final char BACK_SLASH

      See Also:
        Constant Field Values

    - #### BUF_SIZE

          public static final int BUF_SIZE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Zip

          public Zip()

      Creates a new Zip instance.

  - ### Method Detail

    - #### compress

          public void compress(java.io.File file)
                        throws ArchiveException

      Creates a new ZIP archive.
      Specified by:
        `compress` in interface `Archive`
      Parameters:
        `file` - the input file
      Throws:
        `ArchiveException` - if error occurs

    - #### compress

          public void compress(java.io.File file,
                               java.io.File targetPath)
                        throws ArchiveException

      Creates a new ZIP archive.
      Specified by:
        `compress` in interface `Archive`
      Parameters:
        `file` - the input file
        `targetPath` - the output file or directory
      Throws:
        `ArchiveException` - if error occurs

    - #### interrupt

          public void interrupt()

      Interrupt this instance & stop any ongoing compression / decompression.

    - #### reset

          public void reset()

      Reset the interrupted flag.

    - #### isInterrupted

          public boolean isInterrupted()

      Returns whether this instance has been interrupted.
      Returns:
        interrupted

    - #### compress

          public void compress(java.io.File output,
                               java.util.Vector sourceVector)
                        throws ArchiveException

      Expects a Vector of files and zips the content to the output file
      Parameters:
        `sourceVector` -
        `output` -
      Throws:
        `ArchiveException`

    - #### getSize

          public long getSize(java.util.Vector files)

      Get size of files in Vector
      Parameters:
        `files` - target files
      Returns:
        size

    - #### getList

          public static java.util.Vector getList(java.lang.String sDir)

      Recursively calculates the list of files.
      Parameters:
        `sDir` -
      Returns:
        vector of files

    - #### decompress

          public void decompress(java.io.File file)
                          throws ArchiveException

      Decompress all the files in given ZIP archive.
      Specified by:
        `decompress` in interface `Archive`
      Parameters:
        `file` - the ZIP file
      Throws:
        `ArchiveException` - if error occurs

    - #### decompress

          public void decompress(java.io.File file,
                                 java.io.File output)
                          throws ArchiveException

      Decompress all the files in given ZIP archive.
      Specified by:
        `decompress` in interface `Archive`
      Parameters:
        `file` - the ZIP file
        `output` - the output directory to decompress files to
      Throws:
        `ArchiveException` - if error occurs

    - #### addArchiveListener

          public void addArchiveListener(ArchiveListener listener)

      Adds listener.
      Specified by:
        `addArchiveListener` in interface `Archive`
      Parameters:
        `listener` - the listener
      See Also:
        `Archive.addArchiveListener(ArchiveListener)`

    - #### removeArchiveListener

          public void removeArchiveListener(ArchiveListener listener)

      Removes listener.
      Specified by:
        `removeArchiveListener` in interface `Archive`
      Parameters:
        `listener` - the listener
      See Also:
        `Archive.removeArchiveListener(ArchiveListener)`

Copyright © JSCAPE LLC. 1999-2021. All Rights Reserved