Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
    
  
  
  
  
    
  
  
    
    
    
    GZIPOutputStream
    open class GZIPOutputStream : DeflaterOutputStream
    
    This class implements a stream filter for writing compressed data in the GZIP file format.
    Summary
    
      
        
          | Public constructors | 
        
          | Creates a new output stream with a default buffer size. | 
        
          | Creates a new output stream with a default buffer size and the specified flush mode. | 
        
          | Creates a new output stream with the specified buffer size. | 
        
          | Creates a new output stream with the specified buffer size and flush mode. | 
      
    
    
      
        
          | Public methods | 
        
          | open Unit | Finishes writing compressed data to the output stream without closing the underlying stream. | 
        
          | open Unit | Writes array of bytes to the compressed output stream. | 
      
    
    
      
        
          | Inherited functions | 
        
          | From class DeflaterOutputStream
                
                  
                    | Unit | close()
                         Writes remaining compressed data to the output stream and closes the underlying stream. |  
                    | Unit | deflate()
                         Writes next block of compressed data to the output stream. |  
                    | Unit | flush()
                         Flushes the compressed output stream. If  syncFlushistruewhen this compressed output stream is constructed, this method first flushes the underlyingcompressorwith the flush modeDeflater.SYNC_FLUSHto force all pending data to be flushed out to the output stream and then flushes the output stream. Otherwise this method only flushes the output stream without flushing thecompressor. |  
                    | Unit | write(b: Int)
                         Writes a byte to the compressed output stream. This method will block until the byte can be written. |  | 
        
          | From class OutputStream
                
                  
                    | OutputStream! | nullOutputStream()
                         Returns a new OutputStreamwhich discards all bytes. The returned stream is initially open. The stream is closed by calling theclose()method. Subsequent calls toclose()have no effect.  While the stream is open, the write(int),write(byte[]), andwrite(byte[], int, int)methods do nothing. After the stream has been closed, these methods all throwIOException.  The flush()method does nothing. |  | 
        
          | From class FilterOutputStream
                
                  
                    | Unit | write(b: ByteArray!)
                         Writes b.lengthbytes to this output stream.  The writemethod ofFilterOutputStreamcalls itswritemethod of three arguments with the argumentsb,0, andb.length.  Note that this method does not call the one-argument writemethod of its underlying output stream with the single argumentb. |  | 
      
    
    
      
        
          | Properties | 
        
          | CRC32! | CRC-32 of uncompressed data. | 
      
    
    
    Public constructors
    
      GZIPOutputStream
      
      GZIPOutputStream(out: OutputStream!)
      Creates a new output stream with a default buffer size. 
      The new output stream instance is created as if by invoking the 2-argument constructor GZIPOutputStream(out, false).
      
      
        
          
            | Exceptions | 
          
            | java.io.IOException | If an I/O error has occurred. | 
        
      
     
    
      GZIPOutputStream
      
      GZIPOutputStream(
    out: OutputStream!, 
    syncFlush: Boolean)
      Creates a new output stream with a default buffer size and the specified flush mode.
      
        
          
            | Parameters | 
          
            | out | OutputStream!: the output stream | 
          
            | syncFlush | Boolean: if trueinvocation of the inherited java.util.zip.DeflaterOutputStream#flush() method of this instance flushes the compressor with flush modeDeflater.SYNC_FLUSHbefore flushing the output stream, otherwise only flushes the output stream | 
        
      
      
        
          
            | Exceptions | 
          
            | java.io.IOException | If an I/O error has occurred. | 
        
      
     
    
      GZIPOutputStream
      
      GZIPOutputStream(
    out: OutputStream!, 
    size: Int)
      Creates a new output stream with the specified buffer size. 
      The new output stream instance is created as if by invoking the 3-argument constructor GZIPOutputStream(out, size, false). Android-note: Android limits the number of UnbufferedIO operations that can be performed, so consider using buffered inputs with this class. More information can be found in the  UnbufferedIO and  StrictMode documentation.
      
        
          
            | Parameters | 
          
            | out | OutputStream!: the output stream | 
          
            | size | Int: the output buffer size | 
        
      
      
        
          
            | Exceptions | 
          
            | java.io.IOException | If an I/O error has occurred. | 
          
            | java.lang.IllegalArgumentException | if size <= 0 | 
        
      
     
    
      GZIPOutputStream
      
      GZIPOutputStream(
    out: OutputStream!, 
    size: Int, 
    syncFlush: Boolean)
      Creates a new output stream with the specified buffer size and flush mode.
      
        
          
            | Parameters | 
          
            | out | OutputStream!: the output stream | 
          
            | size | Int: the output buffer size | 
          
            | syncFlush | Boolean: if trueinvocation of the inherited java.util.zip.DeflaterOutputStream#flush() method of this instance flushes the compressor with flush modeDeflater.SYNC_FLUSHbefore flushing the output stream, otherwise only flushes the output stream | 
        
      
      
        
          
            | Exceptions | 
          
            | java.io.IOException | If an I/O error has occurred. | 
          
            | java.lang.IllegalArgumentException | if size <= 0 | 
        
      
     
    Public methods
    
      finish
      
      open fun finish(): Unit
      Finishes writing compressed data to the output stream without closing the underlying stream. Use this method when applying multiple filters in succession to the same output stream.
      
        
          
            | Exceptions | 
          
            | java.io.IOException | if an I/O error has occurred | 
        
      
     
    
      write
      
      open fun write(
    buf: ByteArray!, 
    off: Int, 
    len: Int
): Unit
      Writes array of bytes to the compressed output stream. This method will block until all the bytes are written.
      
        
          
            | Parameters | 
          
            | b | the data to be written | 
          
            | off | Int: the start offset of the data | 
          
            | len | Int: the length of the data | 
          
            | buf | ByteArray!: the data to be written | 
        
      
      
        
          
            | Exceptions | 
          
            | java.io.IOException | If an I/O error has occurred. | 
        
      
     
    Properties
    
      crc
      
      protected var crc: CRC32!
      CRC-32 of uncompressed data.
     
  
  
  
    
  
 
  
    
    
      
       
    
    
  
  
  Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
  Last updated 2025-02-10 UTC.
  
  
  
    
      [null,null,["Last updated 2025-02-10 UTC."],[],[]]