/// <summary> /// Opens a new <code>ZipFile</code> to read from the specified /// <code>File</code> object in the specified mode. The mode argument /// must be either <tt>OPEN_READ</tt> or <tt>OPEN_READ | OPEN_DELETE</tt>. /// /// <para>First, if there is a security manager, its <code>checkRead</code> /// method is called with the <code>name</code> argument as its argument to /// ensure the read is allowed. /// /// </para> /// </summary> /// <param name="file"> the ZIP file to be opened for reading </param> /// <param name="mode"> the mode in which the file is to be opened </param> /// <param name="charset"> /// the <seealso cref="java.nio.charset.Charset charset"/> to /// be used to decode the ZIP entry name and comment that are not /// encoded by using UTF-8 encoding (indicated by entry's general /// purpose flag). /// </param> /// <exception cref="ZipException"> if a ZIP format error has occurred </exception> /// <exception cref="IOException"> if an I/O error has occurred /// </exception> /// <exception cref="SecurityException"> /// if a security manager exists and its <code>checkRead</code> /// method doesn't allow read access to the file,or its /// <code>checkDelete</code> method doesn't allow deleting the /// file when the <tt>OPEN_DELETE</tt> flag is set /// </exception> /// <exception cref="IllegalArgumentException"> if the <tt>mode</tt> argument is invalid /// </exception> /// <seealso cref= SecurityManager#checkRead(java.lang.String) /// /// @since 1.7 </seealso> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public ZipFile(java.io.File file, int mode, java.nio.charset.Charset charset) throws java.io.IOException public ZipFile(File file, int mode, Charset charset) { if (((mode & OPEN_READ) == 0) || ((mode & ~(OPEN_READ | OPEN_DELETE)) != 0)) { throw new IllegalArgumentException("Illegal mode: 0x" + mode.ToString("x")); } String name = file.Path; SecurityManager sm = System.SecurityManager; if (sm != null) { sm.CheckRead(name); if ((mode & OPEN_DELETE) != 0) { sm.CheckDelete(name); } } if (charset == null) { throw new NullPointerException("charset is null"); } this.Zc = ZipCoder.Get(charset); long t0 = System.nanoTime(); Jzfile = open(name, mode, file.LastModified(), Usemmap); sun.misc.PerfCounter.ZipFileOpenTime.addElapsedTimeFrom(t0); sun.misc.PerfCounter.ZipFileCount.increment(); this.Name_Renamed = name; this.Total = getTotal(Jzfile); this.Locsig = startsWithLOC(Jzfile); }
/// <summary> /// Creates a new ZIP output stream. /// </summary> /// <param name="out"> the actual output stream /// </param> /// <param name="charset"> the <seealso cref="java.nio.charset.Charset charset"/> /// to be used to encode the entry names and comments /// /// @since 1.7 </param> public ZipOutputStream(OutputStream @out, Charset charset) : base(@out, new Deflater(Deflater.DEFAULT_COMPRESSION, true)) { if (charset == null) { throw new NullPointerException("charset is null"); } this.Zc = ZipCoder.Get(charset); UsesDefaultDeflater = true; }
internal String ToStringUTF8(sbyte[] ba, int len) { if (IsUTF8) { return(ToString(ba, len)); } if (Utf8 == null) { Utf8 = new ZipCoder(StandardCharsets.UTF_8); } return(Utf8.ToString(ba, len)); }
// assume invoked only if "this" is not utf8 internal sbyte[] GetBytesUTF8(String s) { if (IsUTF8) { return(GetBytes(s)); } if (Utf8 == null) { Utf8 = new ZipCoder(StandardCharsets.UTF_8); } return(Utf8.GetBytes(s)); }
/// <summary> /// Creates a new ZIP input stream. /// </summary> /// <param name="in"> the actual input stream /// </param> /// <param name="charset"> /// The <seealso cref="java.nio.charset.Charset charset"/> to be /// used to decode the ZIP entry name (ignored if the /// <a href="package-summary.html#lang_encoding"> language /// encoding bit</a> of the ZIP entry's general purpose bit /// flag is set). /// /// @since 1.7 </param> public ZipInputStream(InputStream @in, Charset charset) : base(new PushbackInputStream(@in, 512), new Inflater(true), 512) { UsesDefaultInflater = true; if (@in == null) { throw new NullPointerException("in is null"); } if (charset == null) { throw new NullPointerException("charset is null"); } this.Zc = ZipCoder.Get(charset); }