다음을 통해 공유


Deflater Class

Definition

This class provides support for general purpose compression using the popular ZLIB compression library.

[Android.Runtime.Register("java/util/zip/Deflater", DoNotGenerateAcw=true)]
public class Deflater : Java.Lang.Object
[<Android.Runtime.Register("java/util/zip/Deflater", DoNotGenerateAcw=true)>]
type Deflater = class
    inherit Object
Inheritance
Deflater
Attributes

Remarks

This class provides support for general purpose compression using the popular ZLIB compression library. The ZLIB compression library was initially developed as part of the PNG graphics standard and is not protected by patents. It is fully described in the specifications at the java.util.zip package description.

The following code fragment demonstrates a trivial compression and decompression of a string using Deflater and Inflater.

<blockquote>

try {
                // Encode a String into bytes
                String inputString = "blahblahblah";
                byte[] input = inputString.getBytes("UTF-8");

                // Compress the bytes
                byte[] output = new byte[100];
                Deflater compresser = new Deflater();
                compresser.setInput(input);
                compresser.finish();
                int compressedDataLength = compresser.deflate(output);
                compresser.end();

                // Decompress the bytes
                Inflater decompresser = new Inflater();
                decompresser.setInput(output, 0, compressedDataLength);
                byte[] result = new byte[100];
                int resultLength = decompresser.inflate(result);
                decompresser.end();

                // Decode the bytes into a String
                String outputString = new String(result, 0, resultLength, "UTF-8");
            } catch(java.io.UnsupportedEncodingException ex) {
                // handle
            } catch (java.util.zip.DataFormatException ex) {
                // handle
            }

</blockquote>

Java documentation for java.util.zip.Deflater.

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.

Constructors

Deflater()

Creates a new compressor with the default compression level.

Deflater(Int32, Boolean)

Creates a new compressor using the specified compression level.

Deflater(Int32)

Creates a new compressor using the specified compression level.

Deflater(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Fields

BestCompression

Compression level for best compression.

BestSpeed

Compression level for fastest compression.

DefaultCompression

Default compression level.

DefaultStrategy

Default compression strategy.

Deflated

Compression method for the deflate algorithm (the only one currently supported).

Filtered

Compression strategy best used for data consisting mostly of small values with a somewhat random distribution.

FullFlush

Compression flush mode used to flush out all pending output and reset the deflater.

HuffmanOnly

Compression strategy for Huffman coding only.

NoCompression

Compression level for no compression.

NoFlush

Compression flush mode used to achieve best compression result.

SyncFlush

Compression flush mode used to flush out all pending output; may degrade compression for some compression algorithms.

Properties

Adler

Returns the ADLER-32 value of the uncompressed data.

BytesRead

Returns the total number of uncompressed bytes input so far.

BytesWritten

Returns the total number of compressed bytes output so far.

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

TotalIn

Returns the total number of uncompressed bytes input so far.

TotalOut

Returns the total number of compressed bytes output so far.

Methods

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Deflate(Byte[], Int32, Int32, Int32)

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

Deflate(Byte[], Int32, Int32)

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

Deflate(Byte[])

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

DeflateAsync(Byte[], Int32, Int32, Int32)
DeflateAsync(Byte[], Int32, Int32)
DeflateAsync(Byte[])
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
End()

Closes the compressor and discards any unprocessed input.

Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
Finish()

When called, indicates that compression should end with the current contents of the input buffer.

Finished()

Returns true if the end of the compressed data output stream has been reached.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
NeedsInput()

Returns true if the input data buffer is empty and setInput() should be called in order to provide more input.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
Reset()

Resets deflater so that a new set of input data can be processed.

SetDictionary(Byte[], Int32, Int32)

Sets preset dictionary for compression.

SetDictionary(Byte[])

Sets preset dictionary for compression.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetInput(Byte[], Int32, Int32)

Sets input data for compression.

SetInput(Byte[])

Sets input data for compression.

SetLevel(Int32)

Sets the compression level to the specified value.

SetStrategy(Int32)

Sets the compression strategy to the specified value.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to