Dela via


Pack200 Class

Definition

Transforms a JAR file to or from a packed stream in Pack200 format.

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

Remarks

Transforms a JAR file to or from a packed stream in Pack200 format. Please refer to Network Transfer Format JSR 200 Specification at http://jcp.org/aboutJava/communityprocess/review/jsr200/index.html

Typically the packer engine is used by application developers to deploy or host JAR files on a website. The unpacker engine is used by deployment applications to transform the byte-stream back to JAR format.

Here is an example using packer and unpacker:

{@code
               import java.util.jar.Pack200;
               import java.util.jar.Pack200.*;
               ...
               // Create the Packer object
               Packer packer = Pack200.newPacker();

               // Initialize the state by setting the desired properties
               Map p = packer.properties();
               // take more time choosing codings for better compression
               p.put(Packer.EFFORT, "7");  // default is "5"
               // use largest-possible archive segments (>10% better compression).
               p.put(Packer.SEGMENT_LIMIT, "-1");
               // reorder files for better compression.
               p.put(Packer.KEEP_FILE_ORDER, Packer.FALSE);
               // smear modification times to a single value.
               p.put(Packer.MODIFICATION_TIME, Packer.LATEST);
               // ignore all JAR deflation requests,
               // transmitting a single request to use "store" mode.
               p.put(Packer.DEFLATE_HINT, Packer.FALSE);
               // discard debug attributes
               p.put(Packer.CODE_ATTRIBUTE_PFX+"LineNumberTable", Packer.STRIP);
               // throw an error if an attribute is unrecognized
               p.put(Packer.UNKNOWN_ATTRIBUTE, Packer.ERROR);
               // pass one class file uncompressed:
               p.put(Packer.PASS_FILE_PFX+0, "mutants/Rogue.class");
               try {
                   JarFile jarFile = new JarFile("/tmp/testref.jar");
                   FileOutputStream fos = new FileOutputStream("/tmp/test.pack");
                   // Call the packer
                   packer.pack(jarFile, fos);
                   jarFile.close();
                   fos.close();

                   File f = new File("/tmp/test.pack");
                   FileOutputStream fostream = new FileOutputStream("/tmp/test.jar");
                   JarOutputStream jostream = new JarOutputStream(fostream);
                   Unpacker unpacker = Pack200.newUnpacker();
                   // Call the unpacker
                   unpacker.unpack(f, jostream);
                   // Must explicitly close the output.
                   jostream.close();
               } catch (IOException ioe) {
                   ioe.printStackTrace();
               }
            }

A Pack200 file compressed with gzip can be hosted on HTTP/1.1 web servers. The deployment applications can use "Accept-Encoding=pack200-gzip". This indicates to the server that the client application desires a version of the file encoded with Pack200 and further compressed with gzip. Please refer to Java Deployment Guide for more details and techniques.

Unless otherwise noted, passing a null argument to a constructor or method in this class will cause a NullPointerException to be thrown.

Added in 1.5.

Java documentation for java.util.jar.Pack200.

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

Pack200(IntPtr, JniHandleOwnership)

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

Properties

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.

Methods

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

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

(Inherited from Object)
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)
NewPacker()

Obtain new instance of a class that implements Packer.

NewUnpacker()

Obtain new instance of a class that implements Unpacker.

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)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
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