Deflater.Deflate Method

Definition

Overloads

Deflate(Byte[])

Compresses the input data and fills specified buffer with compressed data.

Deflate(Byte[], Int32, Int32)

Compresses the input data and fills specified buffer with compressed data.

Deflate(Byte[], Int32, Int32, Int32)

Compresses the input data and fills the specified buffer with compressed data.

Deflate(Byte[])

Compresses the input data and fills specified buffer with compressed data.

[Android.Runtime.Register("deflate", "([B)I", "GetDeflate_arrayBHandler")]
public virtual int Deflate (byte[]? b);
[<Android.Runtime.Register("deflate", "([B)I", "GetDeflate_arrayBHandler")>]
abstract member Deflate : byte[] -> int
override this.Deflate : byte[] -> int

Parameters

b
Byte[]

the buffer for the compressed data

Returns

the actual number of bytes of compressed data written to the output buffer

Attributes

Remarks

Compresses the input data and fills specified buffer with compressed data. Returns actual number of bytes of compressed data. A return value of 0 indicates that #needsInput() needsInput should be called in order to determine if more input data is required.

This method uses #NO_FLUSH as its compression flush mode. An invocation of this method of the form deflater.deflate(b) yields the same result as the invocation of deflater.deflate(b, 0, b.length, Deflater.NO_FLUSH).

Java documentation for java.util.zip.Deflater.deflate(byte[]).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Deflate(Byte[], Int32, Int32)

Compresses the input data and fills specified buffer with compressed data.

[Android.Runtime.Register("deflate", "([BII)I", "GetDeflate_arrayBIIHandler")]
public virtual int Deflate (byte[]? b, int off, int len);
[<Android.Runtime.Register("deflate", "([BII)I", "GetDeflate_arrayBIIHandler")>]
abstract member Deflate : byte[] * int * int -> int
override this.Deflate : byte[] * int * int -> int

Parameters

b
Byte[]

the buffer for the compressed data

off
Int32

the start offset of the data

len
Int32

the maximum number of bytes of compressed data

Returns

the actual number of bytes of compressed data written to the output buffer

Attributes

Remarks

Compresses the input data and fills specified buffer with compressed data. Returns actual number of bytes of compressed data. A return value of 0 indicates that #needsInput() needsInput should be called in order to determine if more input data is required.

This method uses #NO_FLUSH as its compression flush mode. An invocation of this method of the form deflater.deflate(b, off, len) yields the same result as the invocation of deflater.deflate(b, off, len, Deflater.NO_FLUSH).

Java documentation for java.util.zip.Deflater.deflate(byte[], int, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Deflate(Byte[], Int32, Int32, Int32)

Compresses the input data and fills the specified buffer with compressed data.

[Android.Runtime.Register("deflate", "([BIII)I", "GetDeflate_arrayBIIIHandler")]
public virtual int Deflate (byte[]? b, int off, int len, int flush);
[<Android.Runtime.Register("deflate", "([BIII)I", "GetDeflate_arrayBIIIHandler")>]
abstract member Deflate : byte[] * int * int * int -> int
override this.Deflate : byte[] * int * int * int -> int

Parameters

b
Byte[]

the buffer for the compressed data

off
Int32

the start offset of the data

len
Int32

the maximum number of bytes of compressed data

flush
Int32

the compression flush mode

Returns

the actual number of bytes of compressed data written to the output buffer

Attributes

Exceptions

if flush is invalid.

Remarks

Compresses the input data and fills the specified buffer with compressed data. Returns actual number of bytes of data compressed.

Compression flush mode is one of the following three modes:

<ul> <li>#NO_FLUSH: allows the deflater to decide how much data to accumulate, before producing output, in order to achieve the best compression (should be used in normal use scenario). A return value of 0 in this flush mode indicates that #needsInput() should be called in order to determine if more input data is required.

<li>#SYNC_FLUSH: all pending output in the deflater is flushed, to the specified output buffer, so that an inflater that works on compressed data can get all input data available so far (In particular the #needsInput() returns true after this invocation if enough output space is provided). Flushing with #SYNC_FLUSH may degrade compression for some compression algorithms and so it should be used only when necessary.

<li>#FULL_FLUSH: all pending output is flushed out as with #SYNC_FLUSH. The compression state is reset so that the inflater that works on the compressed output data can restart from this point if previous compressed data has been damaged or if random access is desired. Using #FULL_FLUSH too often can seriously degrade compression. </ul>

In the case of #FULL_FLUSH or #SYNC_FLUSH, if the return value is len, the space available in output buffer b, this method should be invoked again with the same flush parameter and more output space.

Added in 1.7.

Java documentation for java.util.zip.Deflater.deflate(byte[], int, int, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to