Esempio n. 1
0
 /// <summary>
 /// Finishes the stream by calling finish() on the deflater.
 /// </summary>
 public virtual void Finish()
 {
     def.Finish();
     while (!def.Finished())
     {
         int len = def.Deflate(buf, 0, buf.Length);
         if (len <= 0)
         {
             break;
         }
         baseOutputStream.Write(buf, 0, len);
     }
     if (!def.Finished())
     {
         throw new Exception("Can't deflate all input?");
     }
     baseOutputStream.Flush();
 }
        /// <summary>
        /// Writes an array of bytes to the compressed output stream. This
        /// method will block until all the bytes are written. </summary>
        /// <param name="b"> the data to be written </param>
        /// <param name="off"> the start offset of the data </param>
        /// <param name="len"> the length of the data </param>
        /// <exception cref="IOException"> if an I/O error has occurred </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void write(byte[] b, int off, int len) throws java.io.IOException
        public override void Write(sbyte[] b, int off, int len)
        {
            if (Def.Finished())
            {
                throw new IOException("write beyond end of stream");
            }
            if ((off | len | (off + len) | (b.Length - (off + len))) < 0)
            {
                throw new IndexOutOfBoundsException();
            }
            else if (len == 0)
            {
                return;
            }
            if (!Def.Finished())
            {
                Def.SetInput(b, off, len);
                while (!Def.NeedsInput())
                {
                    Deflate();
                }
            }
        }