com.esri.arcgis.system
Class ZipArchive

java.lang.Object
  extended by com.esri.arcgis.system.ZipArchive
All Implemented Interfaces:
com.esri.arcgis.interop.RemoteObjRef, IZipArchive, Serializable

public class ZipArchive
extends Object
implements com.esri.arcgis.interop.RemoteObjRef, 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(Object obj)
          Deprecated. As of ArcGIS 9.2, replaced by normal Java casts.
ZipArchive theZipArchive = (ZipArchive) obj;
 
Method Summary
 void addFile(String inputFile)
          Compresses a file and adds it to the archive.
 void closeArchive()
          Closes the archive.
 void createArchive(String archiveName)
          Creates a new archive.
 boolean equals(Object o)
          Compare this object with another
 void extract(String outputDir)
          Extracts all items in the archive to the output directory.
 void extractFile(String file, String outputDir)
          Extracts a file from the archive to the output directory.
static String getClsid()
          getClsid.
 IEnumBSTR getFileNames()
          Obtains the list of files in the archive.
 int hashCode()
          the hashcode for this object
 void openArchive(String archiveName)
          Opens an existing archive.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.esri.arcgis.interop.RemoteObjRef
getJintegraDispatch, release
 

Constructor Detail

ZipArchive

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

Throws:
IOException - if there are interop problems
UnknownHostException - if there are interop problems

ZipArchive

public ZipArchive(Object obj)
           throws IOException
Deprecated. As of ArcGIS 9.2, replaced by normal Java casts.
ZipArchive theZipArchive = (ZipArchive) obj;

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.

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

getClsid

public static String getClsid()
getClsid.


equals

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

Overrides:
equals in class Object

hashCode

public int hashCode()
the hashcode for this object

Overrides:
hashCode in class Object

openArchive

public void openArchive(String archiveName)
                 throws IOException,
                        AutomationException
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.

Product Availability

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

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

createArchive

public void createArchive(String archiveName)
                   throws IOException,
                          AutomationException
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.

Product Availability

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

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

closeArchive

public void closeArchive()
                  throws IOException,
                         AutomationException
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.

Product Availability

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

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

addFile

public void addFile(String inputFile)
             throws IOException,
                    AutomationException
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.

Product Availability

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

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

getFileNames

public IEnumBSTR getFileNames()
                       throws IOException,
                              AutomationException
Obtains 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.

Product Availability

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

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

extractFile

public void extractFile(String file,
                        String outputDir)
                 throws IOException,
                        AutomationException
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.

Product Availability

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

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

extract

public void extract(String outputDir)
             throws IOException,
                    AutomationException
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.

Product Availability

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

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