????

Your IP : 216.73.216.152


Current Path : /opt/ant/manual/api/org/apache/tools/zip/
Upload File :
Current File : //opt/ant/manual/api/org/apache/tools/zip/ZipFile.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_03) on Tue May 22 06:24:55 CEST 2012 -->
<title>ZipFile (Apache Ant API)</title>
<meta name="date" content="2012-05-22">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
    if (location.href.indexOf('is-external=true') == -1) {
        parent.document.title="ZipFile (Apache Ant API)";
    }
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!--   -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/apache/tools/zip/ZipExtraField.html" title="interface in org.apache.tools.zip"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../org/apache/tools/zip/ZipLong.html" title="class in org.apache.tools.zip"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/apache/tools/zip/ZipFile.html" target="_top">Frames</a></li>
<li><a href="ZipFile.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_top");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!--   -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.tools.zip</div>
<h2 title="Class ZipFile" class="title">Class ZipFile</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>org.apache.tools.zip.ZipFile</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public class <span class="strong">ZipFile</span>
extends java.lang.Object</pre>
<div class="block">Replacement for <code>java.util.ZipFile</code>.

 <p>This class adds support for file name encodings other than UTF-8
 (which is required to work on ZIP files created by native zip tools
 and is able to skip a preamble like the one found in self
 extracting archives.  Furthermore it returns instances of
 <code>org.apache.tools.zip.ZipEntry</code> instead of
 <code>java.util.zip.ZipEntry</code>.</p>

 <p>It doesn't extend <code>java.util.zip.ZipFile</code> as it would
 have to reimplement all methods anyway.  Like
 <code>java.util.ZipFile</code>, it uses RandomAccessFile under the
 covers and supports compressed and uncompressed entries.</p>

 <p>The method signatures mimic the ones of
 <code>java.util.zip.ZipFile</code>, with a couple of exceptions:

 <ul>
   <li>There is no getName method.</li>
   <li>entries has been renamed to getEntries.</li>
   <li>getEntries and getEntry return
   <code>org.apache.tools.zip.ZipEntry</code> instances.</li>
   <li>close is allowed to throw IOException.</li>
 </ul></div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_summary">
<!--   -->
</a>
<h3>Constructor Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><strong><a href="../../../../org/apache/tools/zip/ZipFile.html#ZipFile(java.io.File)">ZipFile</a></strong>(java.io.File&nbsp;f)</code>
<div class="block">Opens the given file for reading, assuming the platform's
 native encoding for file names.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colOne"><code><strong><a href="../../../../org/apache/tools/zip/ZipFile.html#ZipFile(java.io.File, java.lang.String)">ZipFile</a></strong>(java.io.File&nbsp;f,
       java.lang.String&nbsp;encoding)</code>
<div class="block">Opens the given file for reading, assuming the specified
 encoding for file names and scanning for unicode extra fields.</div>
</td>
</tr>
<tr class="altColor">
<td class="colOne"><code><strong><a href="../../../../org/apache/tools/zip/ZipFile.html#ZipFile(java.io.File, java.lang.String, boolean)">ZipFile</a></strong>(java.io.File&nbsp;f,
       java.lang.String&nbsp;encoding,
       boolean&nbsp;useUnicodeExtraFields)</code>
<div class="block">Opens the given file for reading, assuming the specified
 encoding for file names.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colOne"><code><strong><a href="../../../../org/apache/tools/zip/ZipFile.html#ZipFile(java.lang.String)">ZipFile</a></strong>(java.lang.String&nbsp;name)</code>
<div class="block">Opens the given file for reading, assuming the platform's
 native encoding for file names.</div>
</td>
</tr>
<tr class="altColor">
<td class="colOne"><code><strong><a href="../../../../org/apache/tools/zip/ZipFile.html#ZipFile(java.lang.String, java.lang.String)">ZipFile</a></strong>(java.lang.String&nbsp;name,
       java.lang.String&nbsp;encoding)</code>
<div class="block">Opens the given file for reading, assuming the specified
 encoding for file names, scanning unicode extra fields.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!--   -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/tools/zip/ZipFile.html#close()">close</a></strong>()</code>
<div class="block">Closes the archive.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/tools/zip/ZipFile.html#closeQuietly(org.apache.tools.zip.ZipFile)">closeQuietly</a></strong>(<a href="../../../../org/apache/tools/zip/ZipFile.html" title="class in org.apache.tools.zip">ZipFile</a>&nbsp;zipfile)</code>
<div class="block">close a zipfile quietly; throw no io fault, do nothing
 on a null parameter</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>protected static java.util.Date</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/tools/zip/ZipFile.html#fromDosTime(org.apache.tools.zip.ZipLong)">fromDosTime</a></strong>(<a href="../../../../org/apache/tools/zip/ZipLong.html" title="class in org.apache.tools.zip">ZipLong</a>&nbsp;zipDosTime)</code>
<div class="block">Convert a DOS date/time field to a Date object.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/tools/zip/ZipFile.html#getEncoding()">getEncoding</a></strong>()</code>
<div class="block">The encoding to use for filenames and the file comment.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>java.util.Enumeration</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/tools/zip/ZipFile.html#getEntries()">getEntries</a></strong>()</code>
<div class="block">Returns all entries.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../org/apache/tools/zip/ZipEntry.html" title="class in org.apache.tools.zip">ZipEntry</a></code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/tools/zip/ZipFile.html#getEntry(java.lang.String)">getEntry</a></strong>(java.lang.String&nbsp;name)</code>
<div class="block">Returns a named entry - or <code>null</code> if no entry by
 that name exists.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>java.io.InputStream</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/tools/zip/ZipFile.html#getInputStream(org.apache.tools.zip.ZipEntry)">getInputStream</a></strong>(<a href="../../../../org/apache/tools/zip/ZipEntry.html" title="class in org.apache.tools.zip">ZipEntry</a>&nbsp;ze)</code>
<div class="block">Returns an InputStream for reading the contents of the given entry.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>protected java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/tools/zip/ZipFile.html#getString(byte[])">getString</a></strong>(byte[]&nbsp;bytes)</code>
<div class="block">Retrieve a String from the given bytes using the encoding set
 for this ZipFile.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!--   -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_detail">
<!--   -->
</a>
<h3>Constructor Detail</h3>
<a name="ZipFile(java.io.File)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>ZipFile</h4>
<pre>public&nbsp;ZipFile(java.io.File&nbsp;f)
        throws java.io.IOException</pre>
<div class="block">Opens the given file for reading, assuming the platform's
 native encoding for file names.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>f</code> - the archive.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.io.IOException</code> - if an error occurs while reading the file.</dd></dl>
</li>
</ul>
<a name="ZipFile(java.lang.String)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>ZipFile</h4>
<pre>public&nbsp;ZipFile(java.lang.String&nbsp;name)
        throws java.io.IOException</pre>
<div class="block">Opens the given file for reading, assuming the platform's
 native encoding for file names.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>name</code> - name of the archive.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.io.IOException</code> - if an error occurs while reading the file.</dd></dl>
</li>
</ul>
<a name="ZipFile(java.lang.String, java.lang.String)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>ZipFile</h4>
<pre>public&nbsp;ZipFile(java.lang.String&nbsp;name,
       java.lang.String&nbsp;encoding)
        throws java.io.IOException</pre>
<div class="block">Opens the given file for reading, assuming the specified
 encoding for file names, scanning unicode extra fields.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>name</code> - name of the archive.</dd><dd><code>encoding</code> - the encoding to use for file names</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.io.IOException</code> - if an error occurs while reading the file.</dd></dl>
</li>
</ul>
<a name="ZipFile(java.io.File, java.lang.String)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>ZipFile</h4>
<pre>public&nbsp;ZipFile(java.io.File&nbsp;f,
       java.lang.String&nbsp;encoding)
        throws java.io.IOException</pre>
<div class="block">Opens the given file for reading, assuming the specified
 encoding for file names and scanning for unicode extra fields.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>f</code> - the archive.</dd><dd><code>encoding</code> - the encoding to use for file names, use null
 for the platform's default encoding</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.io.IOException</code> - if an error occurs while reading the file.</dd></dl>
</li>
</ul>
<a name="ZipFile(java.io.File, java.lang.String, boolean)">
<!--   -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>ZipFile</h4>
<pre>public&nbsp;ZipFile(java.io.File&nbsp;f,
       java.lang.String&nbsp;encoding,
       boolean&nbsp;useUnicodeExtraFields)
        throws java.io.IOException</pre>
<div class="block">Opens the given file for reading, assuming the specified
 encoding for file names.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>f</code> - the archive.</dd><dd><code>encoding</code> - the encoding to use for file names, use null
 for the platform's default encoding</dd><dd><code>useUnicodeExtraFields</code> - whether to use InfoZIP Unicode
 Extra Fields (if present) to set the file names.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.io.IOException</code> - if an error occurs while reading the file.</dd></dl>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!--   -->
</a>
<h3>Method Detail</h3>
<a name="getEncoding()">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getEncoding</h4>
<pre>public&nbsp;java.lang.String&nbsp;getEncoding()</pre>
<div class="block">The encoding to use for filenames and the file comment.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>null if using the platform's default character encoding.</dd></dl>
</li>
</ul>
<a name="close()">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>close</h4>
<pre>public&nbsp;void&nbsp;close()
           throws java.io.IOException</pre>
<div class="block">Closes the archive.</div>
<dl><dt><span class="strong">Throws:</span></dt>
<dd><code>java.io.IOException</code> - if an error occurs closing the archive.</dd></dl>
</li>
</ul>
<a name="closeQuietly(org.apache.tools.zip.ZipFile)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>closeQuietly</h4>
<pre>public static&nbsp;void&nbsp;closeQuietly(<a href="../../../../org/apache/tools/zip/ZipFile.html" title="class in org.apache.tools.zip">ZipFile</a>&nbsp;zipfile)</pre>
<div class="block">close a zipfile quietly; throw no io fault, do nothing
 on a null parameter</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>zipfile</code> - file to close, can be null</dd></dl>
</li>
</ul>
<a name="getEntries()">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getEntries</h4>
<pre>public&nbsp;java.util.Enumeration&nbsp;getEntries()</pre>
<div class="block">Returns all entries.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>all entries as <a href="../../../../org/apache/tools/zip/ZipEntry.html" title="class in org.apache.tools.zip"><code>ZipEntry</code></a> instances</dd></dl>
</li>
</ul>
<a name="getEntry(java.lang.String)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getEntry</h4>
<pre>public&nbsp;<a href="../../../../org/apache/tools/zip/ZipEntry.html" title="class in org.apache.tools.zip">ZipEntry</a>&nbsp;getEntry(java.lang.String&nbsp;name)</pre>
<div class="block">Returns a named entry - or <code>null</code> if no entry by
 that name exists.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>name</code> - name of the entry.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the ZipEntry corresponding to the given name - or
 <code>null</code> if not present.</dd></dl>
</li>
</ul>
<a name="getInputStream(org.apache.tools.zip.ZipEntry)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getInputStream</h4>
<pre>public&nbsp;java.io.InputStream&nbsp;getInputStream(<a href="../../../../org/apache/tools/zip/ZipEntry.html" title="class in org.apache.tools.zip">ZipEntry</a>&nbsp;ze)
                                   throws java.io.IOException,
                                          java.util.zip.ZipException</pre>
<div class="block">Returns an InputStream for reading the contents of the given entry.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>ze</code> - the entry to get the stream for.</dd>
<dt><span class="strong">Returns:</span></dt><dd>a stream to read the entry from.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.io.IOException</code> - if unable to create an input stream from the zipenty</dd>
<dd><code>java.util.zip.ZipException</code> - if the zipentry has an unsupported
 compression method</dd></dl>
</li>
</ul>
<a name="fromDosTime(org.apache.tools.zip.ZipLong)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>fromDosTime</h4>
<pre>protected static&nbsp;java.util.Date&nbsp;fromDosTime(<a href="../../../../org/apache/tools/zip/ZipLong.html" title="class in org.apache.tools.zip">ZipLong</a>&nbsp;zipDosTime)</pre>
<div class="block">Convert a DOS date/time field to a Date object.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>zipDosTime</code> - contains the stored DOS time.</dd>
<dt><span class="strong">Returns:</span></dt><dd>a Date instance corresponding to the given time.</dd></dl>
</li>
</ul>
<a name="getString(byte[])">
<!--   -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>getString</h4>
<pre>protected&nbsp;java.lang.String&nbsp;getString(byte[]&nbsp;bytes)
                              throws java.util.zip.ZipException</pre>
<div class="block">Retrieve a String from the given bytes using the encoding set
 for this ZipFile.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>bytes</code> - the byte array to transform</dd>
<dt><span class="strong">Returns:</span></dt><dd>String obtained by using the given encoding</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.util.zip.ZipException</code> - if the encoding cannot be recognized.</dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!--   -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/apache/tools/zip/ZipExtraField.html" title="interface in org.apache.tools.zip"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../org/apache/tools/zip/ZipLong.html" title="class in org.apache.tools.zip"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/apache/tools/zip/ZipFile.html" target="_top">Frames</a></li>
<li><a href="ZipFile.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_bottom");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!--   -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>