1 *java.util.jar.Pack200* *Pack200* Transforms a JAR file to or from a packed stre
3 public abstract class Pack200
4 extends |java.lang.Object|
6 |java.util.jar.Pack200_Description|
7 |java.util.jar.Pack200_Fields|
8 |java.util.jar.Pack200_Constructors|
9 |java.util.jar.Pack200_Methods|
11 ================================================================================
13 *java.util.jar.Pack200_Methods*
14 |java.util.jar.Pack200.newPacker()|Obtain new instance of a class that implemen
15 |java.util.jar.Pack200.newUnpacker()|Obtain new instance of a class that implem
17 *java.util.jar.Pack200_Description*
19 Transforms a JAR file to or from a packed stream in Pack200 format. Please
20 refer to Network Trasfer Format JSR 200 Specification at
21 http://jcp.org/aboutJava/communityprocess/review/jsr200/index.html
23 Typically the packer engine is used by application developers to deploy or host
24 JAR files on a website. The unpacker engine is used by deployment applications
25 to transform the byte-stream back to JAR format.
27 Here is an example using packer and unpacker:
29 import java.util.jar.Pack200; import java.util.jar.Pack200.*; ... // Create the
30 Packer object Packer packer = Pack200.newPacker();
32 // Initialize the state by setting the desired properties Map p =
33 packer.properties(); // take more time choosing codings for better compression
34 p.put(Packer.EFFORT, "7"); // default is "5" // use largest-possible archive
35 segments (>10% better compression). p.put(Packer.SEGMENT_LIMIT, "-1"); //
36 reorder files for better compression. p.put(Packer.KEEP_FILE_ORDER,
37 Packer.FALSE); // smear modification times to a single value.
38 p.put(Packer.MODIFICATION_TIME, Packer.LATEST); // ignore all JAR deflation
39 requests, // transmitting a single request to use "store" mode.
40 p.put(Packer.DEFLATE_HINT, Packer.FALSE); // discard debug attributes
41 p.put(Packer.CODE_ATTRIBUTE_PFX+"LineNumberTable", Packer.STRIP); // throw an
42 error if an attribute is unrecognized p.put(Packer.UNKNOWN_ATTRIBUTE,
43 Packer.ERROR); // pass one class file uncompressed:
44 p.put(Packer.PASS_FILE_PFX+0, "mutants/Rogue.class"); try { JarFile jarFile =
45 new JarFile("/tmp/testref.jar"); FileOutputStream fos = new
46 FileOutputStream("/tmp/test.pack"); // Call the packer packer.pack(jarFile,
47 fos); jarFile.close(); fos.close();
49 File f = new File("/tmp/test.pack"); FileOutputStream fostream = new
50 FileOutputStream("/tmp/test.jar"); JarOutputStream jostream = new
51 JarOutputStream(fostream); Unpacker unpacker = Pack200.newUnpacker(); // Call
52 the unpacker unpacker.unpack(f, jostream); // Must explicitly close the output.
53 jostream.close(); } catch (IOException ioe) { ioe.printStackTrace(); }
55 A Pack200 file compressed with gzip can be hosted on HTTP/1.1 web servers. The
56 deployment applications can use "Accept-Encoding=pack200-gzip". This indicates
57 to the server that the client application desires a version of the file encoded
58 with Pack200 and further compressed with gzip. Please refer to Java Deployment
59 Guide for more details and techniques.
61 Unless otherwise noted, passing a null argument to a constructor or method in
62 this class will cause a (|java.lang.NullPointerException|) to be thrown.
65 *java.util.jar.Pack200.newPacker()*
67 public static synchronized |java.util.jar.Pack200.Packer| newPacker()
69 Obtain new instance of a class that implements Packer.
71 If the system property java.util.jar.Pack200.Packer is defined, then the value
72 is taken to be the fully-qualified name of a concrete implementation class,
73 which must implement Packer. This class is loaded and instantiated. If this
74 process fails then an unspecified error is thrown.
76 If an implementation has not been specified with the system property, then the
77 system-default implementation class is instantiated, and the result is
80 Note: The returned object is not guaranteed to operate correctly if multiple
81 threads use it at the same time. A multi-threaded application should either
82 allocate multiple packer engines, or else serialize use of one engine with a
86 Returns: A newly allocated Packer engine.
87 *java.util.jar.Pack200.newUnpacker()*
89 public static |java.util.jar.Pack200.Unpacker| newUnpacker()
91 Obtain new instance of a class that implements Unpacker.
93 If the system property java.util.jar.Pack200.Unpacker is defined, then the
94 value is taken to be the fully-qualified name of a concrete implementation
95 class, which must implement Unpacker. The class is loaded and instantiated. If
96 this process fails then an unspecified error is thrown.
98 If an implementation has not been specified with the system property, then the
99 system-default implementation class is instantiated, and the result is
102 Note: The returned object is not guaranteed to operate correctly if multiple
103 threads use it at the same time. A multi-threaded application should either
104 allocate multiple unpacker engines, or else serialize use of one engine with a
108 Returns: A newly allocated Unpacker engine.