com.esri.arcgis.system
Class ZipArchive

java.lang.Object
  extended bycom.esri.arcgis.system.ZipArchive
All Implemented Interfaces:
IZipArchive, java.io.Serializable

public class ZipArchive
extends java.lang.Object
implements IZipArchive

The ZipArchive object which manages zip archives.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

See Also:
Serialized Form

Constructor Summary
ZipArchive()
          Constructs a ZipArchive using ArcGIS Engine.
ZipArchive(java.lang.Object obj)
          Deprecated. As of ArcGIS 9.2, replaced by normal Java casts.
 
Method Summary
 void addFile(java.lang.String inputFile)
          Compresses a file and adds it to the archive.
 void closeArchive()
          Closes the archive.
 void createArchive(java.lang.String archiveName)
          Creates a new archive.
 boolean equals(java.lang.Object o)
          Compare this object with another
 void extract(java.lang.String outputDir)
          Extracts all items in the archive to the output directory.
 void extractFile(java.lang.String file, java.lang.String outputDir)
          Extracts a file from the archive to the output directory.
 IZipArchive getAsIZipArchive()
          Deprecated. No replacement. The object reference can be directly used where the implemented interface is needed.
static java.lang.String getClsid()
           
 IEnumBSTR getFileNames()
          Gets the list of files in the archive.
 int hashCode()
          the hashcode for this object
 void openArchive(java.lang.String archiveName)
          Opens an existing archive.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZipArchive

public ZipArchive()
           throws java.io.IOException,
                  java.net.UnknownHostException
Constructs a ZipArchive using ArcGIS Engine.

Throws:
java.io.IOException - if there are interop problems
java.net.UnknownHostException - if there are interop problems

ZipArchive

public ZipArchive(java.lang.Object obj)
           throws java.io.IOException
Deprecated. As of ArcGIS 9.2, replaced by normal Java casts.

Construct a ZipArchive using a reference to such an object returned from ArcGIS Engine or Server. This is semantically equivalent to casting obj to ZipArchive.
ZipArchive theZipArchive = (ZipArchive) obj;

Parameters:
obj - an object returned from ArcGIS Engine or Server
Throws:
java.io.IOException - if there are interop problems
Method Detail

getClsid

public static java.lang.String getClsid()

getAsIZipArchive

public IZipArchive getAsIZipArchive()
Deprecated. No replacement. The object reference can be directly used where the implemented interface is needed.


equals

public boolean equals(java.lang.Object o)
Compare this object with another


hashCode

public int hashCode()
the hashcode for this object


openArchive

public void openArchive(java.lang.String archiveName)
                 throws java.io.IOException,
                        AutomationException
Description copied from interface: IZipArchive
Opens an existing archive.

Description

Opens an existing zip archive with the specified file name.

Ensure the zip archive you want to open is not empty, as OpenArchive method would fail if the archive doesn't contain anything in it.

Specified by:
openArchive in interface IZipArchive
Parameters:
archiveName - The archiveName (in)
Throws:
java.io.IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

createArchive

public void createArchive(java.lang.String archiveName)
                   throws java.io.IOException,
                          AutomationException
Description copied from interface: IZipArchive
Creates a new archive.

Description

Creates a new zip archive with the specified file name. The file name must include the zip extension (*.zip).

If a zip archive with the specified file name already exists it will automatically be replaced with a new empty zip archive and the contents of the previous zip archive will be lost.

Specified by:
createArchive in interface IZipArchive
Parameters:
archiveName - The archiveName (in)
Throws:
AutomationException - If the ArcObject component throws an exception.
java.io.IOException - If there are interop problems.

closeArchive

public void closeArchive()
                  throws java.io.IOException,
                         AutomationException
Description copied from interface: IZipArchive
Closes the archive.

Description

Closes the zip archive. In order to open an archive use either the CreateArchive (create a new archive) or OpenArchive (open existing one) methods.

Specified by:
closeArchive in interface IZipArchive
Throws:
java.io.IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

addFile

public void addFile(java.lang.String inputFile)
             throws java.io.IOException,
                    AutomationException
Description copied from interface: IZipArchive
Compresses a file and adds it to the archive.

Description

Compresses and adds the specified file to the zip archive. Ensure the zip archive is open before using the AddFile method by either using the CreateArchive (if you just created an archive) or OpenArchive (if you are using a previously created archive) methods.

Note, you cannot use the AddFile method to add the contents of a directory to a zip archive.

Specified by:
addFile in interface IZipArchive
Parameters:
inputFile - The inputFile (in)
Throws:
java.io.IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getFileNames

public IEnumBSTR getFileNames()
                       throws java.io.IOException,
                              AutomationException
Description copied from interface: IZipArchive
Gets the list of files in the archive.

Description

Returns an enumeration of file names in the zip archive. Ensure the zip archive is open before using the GetFileNames method by using the OpenArchive method.

Specified by:
getFileNames in interface IZipArchive
Returns:
A reference to a com.esri.arcgis.system.IEnumBSTR
Throws:
java.io.IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

extractFile

public void extractFile(java.lang.String file,
                        java.lang.String outputDir)
                 throws java.io.IOException,
                        AutomationException
Description copied from interface: IZipArchive
Extracts a file from the archive to the output directory.

Description

The ExtractFile method extracts the specified compressed file in the zip archive into the specified directory. Use the GetFileNames method to return an enumeration of files in the zip archive. Ensure the zip archive is open before using the ExtractFile method by using the OpenArchive method.

Specified by:
extractFile in interface IZipArchive
Parameters:
file - The file (in)
outputDir - The outputDir (in)
Throws:
AutomationException - If the ArcObject component throws an exception.
java.io.IOException - If there are interop problems.

extract

public void extract(java.lang.String outputDir)
             throws java.io.IOException,
                    AutomationException
Description copied from interface: IZipArchive
Extracts all items in the archive to the output directory.

Description

The Extract method extracts all of the compressed files in the zip archive into the specified directory. Ensure the zip archive is open before using the Extract method by using the OpenArchive method.

Specified by:
extract in interface IZipArchive
Parameters:
outputDir - The outputDir (in)
Throws:
AutomationException - If the ArcObject component throws an exception.
java.io.IOException - If there are interop problems.