Example #1
0
        //throws IOException {

        /**
         * Opens the given file for reading, assuming the specified
         * encoding for file names.
         *
         * @param f the archive.
         * @param encoding the encoding to use for file names, use null
         * for the platform's default encoding
         * @param useUnicodeExtraFields whether to use InfoZIP Unicode
         * Extra Fields (if present) to set the file names.
         *
         * @throws IOException if an error occurs while reading the file.
         */
        public ZipFile(java.io.File f, String encoding, bool useUnicodeExtraFields)
        //throws IOException
        {
            this.OFFSET_COMPARATOR     = new IAC_OFFSET_COMPARATOR(this);
            this.encoding              = encoding;
            this.zipEncoding           = ZipEncodingHelper.getZipEncoding(encoding);
            this.useUnicodeExtraFields = useUnicodeExtraFields;
            archive = new java.io.RandomAccessFile(f, "r");
            bool success = false;

            try {
                java.util.Map <ZipArchiveEntry, IAC_NameAndComment> entriesWithoutUTF8Flag = populateFromCentralDirectory();
                resolveLocalFileHeaderData(entriesWithoutUTF8Flag);
                success = true;
            } finally {
                if (!success)
                {
                    try {
                        archive.close();
                    } catch (java.io.IOException) {
                        // swallow, throw the original exception instead
                    }
                }
            }
        }
 /**
  * @param encoding the encoding to use for file names, use null
  * for the platform's default encoding
  * @param useUnicodeExtraFields whether to use InfoZIP Unicode
  * Extra Fields (if present) to set the file names.
  * @param allowStoredEntriesWithDataDescriptor whether the stream
  * will try to read STORED entries that use a data descriptor
  * @since Apache Commons Compress 1.1
  */
 public ZipArchiveInputStream(java.io.InputStream inputStream,
                              String encoding,
                              bool useUnicodeExtraFields,
                              bool allowStoredEntriesWithDataDescriptor)
 {
     zipEncoding = ZipEncodingHelper.getZipEncoding(encoding);
     this.useUnicodeExtraFields = useUnicodeExtraFields;
     inJ = new java.io.PushbackInputStream(inputStream, buf.Length);
     this.allowStoredEntriesWithDataDescriptor =
         allowStoredEntriesWithDataDescriptor;
 }
 /**
  * The encoding to use for filenames and the file comment.
  *
  * <p>For a list of possible values see <a
  * href="http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html">http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html</a>.
  * Defaults to UTF-8.</p>
  * @param encoding the encoding to use for file names, use null
  * for the platform's default encoding
  */
 public void setEncoding(String encoding)
 {
     this.encoding    = encoding;
     this.zipEncoding = ZipEncodingHelper.getZipEncoding(encoding);
     useUTF8Flag     &= ZipEncodingHelper.isUTF8(encoding);
 }