|
JavaTM Platform Standard Ed. 6 |
|||||||||
��һ���� ��һ���� | ��� ��� ������ | |||||||||
ժҪ�� Ƕ�� | �ֶ� | ���췽�� | ���� | ��ϸ��Ϣ�� �ֶ� | ���췽�� | ���� |
java.lang.Objectjava.util.jar.Pack200
public abstract class Pack200
�� Pack200 ��ʽ�� JAR �ļ��ʹ������֮�����ת���������������ַ�� Network Transfer Format JSR 200 Specification:http://jcp.org/aboutJava/communityprocess/review/jsr200/index.html��
ͨ����Ӧ�ó�����Աʹ�ô������������վ�ϲ�������� JAR �ļ�������Ӧ�ó�����ʹ�ý����������ֽ���ת���� JAR ��ʽ��
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(); }
�� gzip ѹ���� Pack200 �ļ����������� HTTP/1.1 Web �������ϡ�����Ӧ�ó������ʹ�� "Accept-Encoding=pack200-gzip"�����������ָʾ�ͻ���Ӧ�ó�����Ҫ������ Pack200 ���벢�� gzip ��һ��ѹ�����ļ��汾���й�ϸ�ںͼ����ĸ�����Ϣ������� Java Deployment Guide��
��������˵�������� null �������ݸ������еĹ��췽���������׳� NullPointerException
��
Ƕ����ժҪ | |
---|---|
static interface |
Pack200.Packer
���������Ѹ���ת��Ӧ�õ����� JAR �ļ����Ӷ�����ͨ��ѹ�������� gzip �� zip���߶�ѹ��������� |
static interface |
Pack200.Unpacker
��������潫�������ת��Ϊ JAR �ļ��� |
����ժҪ | |
---|---|
static Pack200.Packer |
newPacker()
��ȡһ��ʵ�� Packer ���µ���ʵ���� |
static Pack200.Unpacker |
newUnpacker()
��ȡһ��ʵ�� Unpacker ���µ���ʵ���� |
���� java.lang.Object �̳еķ��� |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
������ϸ��Ϣ |
---|
public static Pack200.Packer newPacker()
���������ϵͳ���� java.util.jar.Pack200.Packer����ô��ֵ��Ϊ����ʵ���ࣨ����ʵ�� Packer������ȫ�����ơ����ز�ʵ�������ࡣ����˽���ʧ�ܣ����׳�δָ������
�����δ��ϵͳ����ָ��ʵ�֣���ôʵ����ϵͳĬ�ϵ�ʵ���ಢ���ؽ����
ע���������߳�ͬʱʹ�÷��صĶ���������֤���صĶ��������ȷ�����߳�Ӧ�ó���Ӧ�÷�������������棬��������һ������˳��ʹ��һ�����档
public static Pack200.Unpacker newUnpacker()
���������ϵͳ���� java.util.jar.Pack200.Unpacker����ô��ֵ��Ϊ����ʵ���ࣨ����ʵ�� Unpacker������ȫ�����ơ����ز�ʵ�������ࡣ����˽���ʧ�ܣ����׳�δָ������
�����δ��ϵͳ����ָ��ʵ�֣���ôʵ����ϵͳĬ�ϵ�ʵ���ಢ���ؽ����
ע���������߳�ͬʱʹ�÷��صĶ���������֤���صĶ��������ȷ�����߳�Ӧ�ó���Ӧ�÷�������������棬��������һ������˳��ʹ��һ�����档
|
JavaTM Platform Standard Ed. 6 |
|||||||||
��һ���� ��һ���� | ��� ��� ������ | |||||||||
ժҪ�� Ƕ�� | �ֶ� | ���췽�� | ���� | ��ϸ��Ϣ�� �ֶ� | ���췽�� | ���� |
��Ȩ���� 2007 Sun Microsystems, Inc. ��������Ȩ���� ����������֤��������������ĵ����·ַ�������