Java 类java.util.jar.Pack200 实例源码

项目:ramus    文件:Pack.java   
/**
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
    if (args.length != 2) {
        System.err.println("command unput-directory output-directory");
        System.exit(1);
    }

    Packer packer = Pack200.newPacker();

    Map p = packer.properties();
    p.put(Packer.EFFORT, "9");
    p.put(Packer.SEGMENT_LIMIT, "-1");
    p.put(Packer.KEEP_FILE_ORDER, Packer.FALSE);
    p.put(Packer.MODIFICATION_TIME, Packer.LATEST);
    p.put(Packer.DEFLATE_HINT, Packer.FALSE);
    p.put(Packer.CODE_ATTRIBUTE_PFX + "LineNumberTable", Packer.STRIP);
    p.put(Packer.UNKNOWN_ATTRIBUTE, Packer.ERROR);

    File inputDirectory = new File(args[0]);

    File outputDirectory = new File(args[1]);

    pack(packer, inputDirectory, outputDirectory);
}
项目:OpenJSharp    文件:PackerImpl.java   
/**
 * Takes a JarFile and converts into a pack-stream.
 * <p>
 * Closes its input but not its output.  (Pack200 archives are appendable.)
 * @param in a JarFile
 * @param out an OutputStream
 * @exception IOException if an error is encountered.
 */
public synchronized void pack(JarFile in, OutputStream out) throws IOException {
    assert(Utils.currentInstance.get() == null);
    TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE))
                  ? null
                  : TimeZone.getDefault();
    try {
        Utils.currentInstance.set(this);
        if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

        if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
            Utils.copyJarFile(in, out);
        } else {
            (new DoPack()).run(in, out);
        }
    } finally {
        Utils.currentInstance.set(null);
        if (tz != null) TimeZone.setDefault(tz);
        in.close();
    }
}
项目:OpenJSharp    文件:PackerImpl.java   
/**
 * Takes a JarInputStream and converts into a pack-stream.
 * <p>
 * Closes its input but not its output.  (Pack200 archives are appendable.)
 * <p>
 * The modification time and deflation hint attributes are not available,
 * for the jar-manifest file and the directory containing the file.
 *
 * @see #MODIFICATION_TIME
 * @see #DEFLATION_HINT
 * @param in a JarInputStream
 * @param out an OutputStream
 * @exception IOException if an error is encountered.
 */
public synchronized void pack(JarInputStream in, OutputStream out) throws IOException {
    assert(Utils.currentInstance.get() == null);
    TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)) ? null :
        TimeZone.getDefault();
    try {
        Utils.currentInstance.set(this);
        if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
        if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
            Utils.copyJarFile(in, out);
        } else {
            (new DoPack()).run(in, out);
        }
    } finally {
        Utils.currentInstance.set(null);
        if (tz != null) TimeZone.setDefault(tz);
        in.close();
    }
}
项目:OpenJSharp    文件:NativeUnpack.java   
private void updateProgress() {
    // Progress is a combination of segment reading and file writing.
    final double READ_WT  = 0.33;
    final double WRITE_WT = 0.67;
    double readProgress = _segCount;
    if (_estByteLimit > 0 && _byteCount > 0)
        readProgress += (double)_byteCount / _estByteLimit;
    double writeProgress = _fileCount;
    double scaledProgress
        = READ_WT  * readProgress  / Math.max(_estSegLimit,1)
        + WRITE_WT * writeProgress / Math.max(_estFileLimit,1);
    int percent = (int) Math.round(100*scaledProgress);
    if (percent > 100)  percent = 100;
    if (percent > _prevPercent) {
        _prevPercent = percent;
        _props.setInteger(Pack200.Unpacker.PROGRESS, percent);
        if (_verbose > 0)
            Utils.log.info("progress = "+percent);
    }
}
项目:jdk8u-jdk    文件:PackerImpl.java   
/**
 * Takes a JarFile and converts into a pack-stream.
 * <p>
 * Closes its input but not its output.  (Pack200 archives are appendable.)
 *
 * @param in  a JarFile
 * @param out an OutputStream
 * @exception IOException if an error is encountered.
 */
public synchronized void pack(JarFile in, OutputStream out) throws IOException {
    assert (Utils.currentInstance.get() == null);

    boolean needUTC = !props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE);
    try {
        Utils.currentInstance.set(this);
        if (needUTC) {
            Utils.changeDefaultTimeZoneToUtc();
        }

        if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
            Utils.copyJarFile(in, out);
        } else {
            (new DoPack()).run(in, out);
        }
    } finally {
        Utils.currentInstance.set(null);
        if (needUTC) {
            Utils.restoreDefaultTimeZone();
        }
        in.close();
    }
}
项目:jdk8u-jdk    文件:PackerImpl.java   
/**
 * Takes a JarInputStream and converts into a pack-stream.
 * <p>
 * Closes its input but not its output.  (Pack200 archives are appendable.)
 * <p>
 * The modification time and deflation hint attributes are not available,
 * for the jar-manifest file and the directory containing the file.
 *
 * @see #MODIFICATION_TIME
 * @see #DEFLATION_HINT
 * @param in a JarInputStream
 * @param out an OutputStream
 * @exception IOException if an error is encountered.
 */
public synchronized void pack(JarInputStream in, OutputStream out) throws IOException {
    assert (Utils.currentInstance.get() == null);
    boolean needUTC = !props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE);
    try {
        Utils.currentInstance.set(this);
        if (needUTC) {
            Utils.changeDefaultTimeZoneToUtc();
        }
        if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
            Utils.copyJarFile(in, out);
        } else {
            (new DoPack()).run(in, out);
        }
    } finally {
        Utils.currentInstance.set(null);
        if (needUTC) {
            Utils.restoreDefaultTimeZone();
        }
        in.close();
    }
}
项目:jdk8u-jdk    文件:NativeUnpack.java   
private void updateProgress() {
    // Progress is a combination of segment reading and file writing.
    final double READ_WT  = 0.33;
    final double WRITE_WT = 0.67;
    double readProgress = _segCount;
    if (_estByteLimit > 0 && _byteCount > 0)
        readProgress += (double)_byteCount / _estByteLimit;
    double writeProgress = _fileCount;
    double scaledProgress
        = READ_WT  * readProgress  / Math.max(_estSegLimit,1)
        + WRITE_WT * writeProgress / Math.max(_estFileLimit,1);
    int percent = (int) Math.round(100*scaledProgress);
    if (percent > 100)  percent = 100;
    if (percent > _prevPercent) {
        _prevPercent = percent;
        _props.setInteger(Pack200.Unpacker.PROGRESS, percent);
        if (_verbose > 0)
            Utils.log.info("progress = "+percent);
    }
}
项目:openjdk-jdk10    文件:NativeUnpack.java   
private void updateProgress() {
    // Progress is a combination of segment reading and file writing.
    final double READ_WT  = 0.33;
    final double WRITE_WT = 0.67;
    double readProgress = _segCount;
    if (_estByteLimit > 0 && _byteCount > 0)
        readProgress += (double)_byteCount / _estByteLimit;
    double writeProgress = _fileCount;
    double scaledProgress
        = READ_WT  * readProgress  / Math.max(_estSegLimit,1)
        + WRITE_WT * writeProgress / Math.max(_estFileLimit,1);
    int percent = (int) Math.round(100*scaledProgress);
    if (percent > 100)  percent = 100;
    if (percent > _prevPercent) {
        _prevPercent = percent;
        _props.setInteger(Pack200.Unpacker.PROGRESS, percent);
        if (_verbose > 0)
            Utils.log.info("progress = "+percent);
    }
}
项目:openjdk9    文件:NativeUnpack.java   
private void updateProgress() {
    // Progress is a combination of segment reading and file writing.
    final double READ_WT  = 0.33;
    final double WRITE_WT = 0.67;
    double readProgress = _segCount;
    if (_estByteLimit > 0 && _byteCount > 0)
        readProgress += (double)_byteCount / _estByteLimit;
    double writeProgress = _fileCount;
    double scaledProgress
        = READ_WT  * readProgress  / Math.max(_estSegLimit,1)
        + WRITE_WT * writeProgress / Math.max(_estFileLimit,1);
    int percent = (int) Math.round(100*scaledProgress);
    if (percent > 100)  percent = 100;
    if (percent > _prevPercent) {
        _prevPercent = percent;
        _props.setInteger(Pack200.Unpacker.PROGRESS, percent);
        if (_verbose > 0)
            Utils.log.info("progress = "+percent);
    }
}
项目:openjdk9    文件:Utils.java   
static void pack(JarFile jarFile, File packFile) throws IOException {
    Pack200.Packer packer = Pack200.newPacker();
    Map<String, String> p = packer.properties();
    // Take the time optimization vs. space
    p.put(packer.EFFORT, "1");  // CAUTION: do not use 0.
    // Make the memory consumption as effective as possible
    p.put(packer.SEGMENT_LIMIT, "10000");
    // ignore all JAR deflation requests to save time
    p.put(packer.DEFLATE_HINT, packer.FALSE);
    // save the file ordering of the original JAR
    p.put(packer.KEEP_FILE_ORDER, packer.TRUE);
    FileOutputStream fos = null;
    try {
        // Write out to a jtreg scratch area
        fos = new FileOutputStream(packFile);
        // Call the packer
        packer.pack(jarFile, fos);
    } finally {
        close(fos);
    }
}
项目:PhET    文件:AppletLoader.java   
/**
 *  Extract Pack File
 *  @param in Input path to pack file
 *  @param out output path to resulting file
 *  @throws Exception if any errors occur
 */
protected void extractPack(String in, String out) throws Exception {
    File f = new File(in);
    FileOutputStream fostream = new FileOutputStream(out);
    JarOutputStream jostream = new JarOutputStream(fostream);

    try {
        Pack200.Unpacker unpacker = Pack200.newUnpacker();
        unpacker.unpack(f, jostream);
    } finally {
        jostream.close();
        fostream.close();
    }

    // delete pack file as its no longer needed
    f.delete();
}
项目:PhET    文件:PackLoader.java   
public void run() {
    Unpacker unpack = Pack200.newUnpacker();
    try {
        long begin = System.currentTimeMillis();
        StreamClassLoader streamClassLoader = new StreamClassLoader();
        if ( inFile != null ) { unpack.unpack( inFile, streamClassLoader ); }
        else { unpack.unpack( in, streamClassLoader ); }
        streamClassLoader.close();

        long unpackingTime = System.currentTimeMillis() - begin;

        Class main = findClass( mainClass );
        Method mainMethod = main.getMethod( "main", String[].class );
        mainMethod.invoke( null, new Object[] { args } );

    }
    catch ( Exception e ) {
        e.printStackTrace();
    }
}
项目:jdk8u_jdk    文件:PackerImpl.java   
/**
 * Takes a JarFile and converts into a pack-stream.
 * <p>
 * Closes its input but not its output.  (Pack200 archives are appendable.)
 *
 * @param in  a JarFile
 * @param out an OutputStream
 * @exception IOException if an error is encountered.
 */
public synchronized void pack(JarFile in, OutputStream out) throws IOException {
    assert (Utils.currentInstance.get() == null);

    boolean needUTC = !props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE);
    try {
        Utils.currentInstance.set(this);
        if (needUTC) {
            Utils.changeDefaultTimeZoneToUtc();
        }

        if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
            Utils.copyJarFile(in, out);
        } else {
            (new DoPack()).run(in, out);
        }
    } finally {
        Utils.currentInstance.set(null);
        if (needUTC) {
            Utils.restoreDefaultTimeZone();
        }
        in.close();
    }
}
项目:jdk8u_jdk    文件:PackerImpl.java   
/**
 * Takes a JarInputStream and converts into a pack-stream.
 * <p>
 * Closes its input but not its output.  (Pack200 archives are appendable.)
 * <p>
 * The modification time and deflation hint attributes are not available,
 * for the jar-manifest file and the directory containing the file.
 *
 * @see #MODIFICATION_TIME
 * @see #DEFLATION_HINT
 * @param in a JarInputStream
 * @param out an OutputStream
 * @exception IOException if an error is encountered.
 */
public synchronized void pack(JarInputStream in, OutputStream out) throws IOException {
    assert (Utils.currentInstance.get() == null);
    boolean needUTC = !props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE);
    try {
        Utils.currentInstance.set(this);
        if (needUTC) {
            Utils.changeDefaultTimeZoneToUtc();
        }
        if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
            Utils.copyJarFile(in, out);
        } else {
            (new DoPack()).run(in, out);
        }
    } finally {
        Utils.currentInstance.set(null);
        if (needUTC) {
            Utils.restoreDefaultTimeZone();
        }
        in.close();
    }
}
项目:jdk8u_jdk    文件:NativeUnpack.java   
private void updateProgress() {
    // Progress is a combination of segment reading and file writing.
    final double READ_WT  = 0.33;
    final double WRITE_WT = 0.67;
    double readProgress = _segCount;
    if (_estByteLimit > 0 && _byteCount > 0)
        readProgress += (double)_byteCount / _estByteLimit;
    double writeProgress = _fileCount;
    double scaledProgress
        = READ_WT  * readProgress  / Math.max(_estSegLimit,1)
        + WRITE_WT * writeProgress / Math.max(_estFileLimit,1);
    int percent = (int) Math.round(100*scaledProgress);
    if (percent > 100)  percent = 100;
    if (percent > _prevPercent) {
        _prevPercent = percent;
        _props.setInteger(Pack200.Unpacker.PROGRESS, percent);
        if (_verbose > 0)
            Utils.log.info("progress = "+percent);
    }
}
项目:jdk8u_jdk    文件:Utils.java   
static void pack(JarFile jarFile, File packFile) throws IOException {
    Pack200.Packer packer = Pack200.newPacker();
    Map<String, String> p = packer.properties();
    // Take the time optimization vs. space
    p.put(packer.EFFORT, "1");  // CAUTION: do not use 0.
    // Make the memory consumption as effective as possible
    p.put(packer.SEGMENT_LIMIT, "10000");
    // ignore all JAR deflation requests to save time
    p.put(packer.DEFLATE_HINT, packer.FALSE);
    // save the file ordering of the original JAR
    p.put(packer.KEEP_FILE_ORDER, packer.TRUE);
    FileOutputStream fos = null;
    try {
        // Write out to a jtreg scratch area
        fos = new FileOutputStream(packFile);
        // Call the packer
        packer.pack(jarFile, fos);
    } finally {
        close(fos);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:PackerImpl.java   
/**
 * Takes a JarFile and converts into a pack-stream.
 * <p>
 * Closes its input but not its output.  (Pack200 archives are appendable.)
 *
 * @param in  a JarFile
 * @param out an OutputStream
 * @exception IOException if an error is encountered.
 */
public synchronized void pack(JarFile in, OutputStream out) throws IOException {
    assert (Utils.currentInstance.get() == null);

    boolean needUTC = !props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE);
    try {
        Utils.currentInstance.set(this);
        if (needUTC) {
            Utils.changeDefaultTimeZoneToUtc();
        }

        if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
            Utils.copyJarFile(in, out);
        } else {
            (new DoPack()).run(in, out);
        }
    } finally {
        Utils.currentInstance.set(null);
        if (needUTC) {
            Utils.restoreDefaultTimeZone();
        }
        in.close();
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:PackerImpl.java   
/**
 * Takes a JarInputStream and converts into a pack-stream.
 * <p>
 * Closes its input but not its output.  (Pack200 archives are appendable.)
 * <p>
 * The modification time and deflation hint attributes are not available,
 * for the jar-manifest file and the directory containing the file.
 *
 * @see #MODIFICATION_TIME
 * @see #DEFLATION_HINT
 * @param in a JarInputStream
 * @param out an OutputStream
 * @exception IOException if an error is encountered.
 */
public synchronized void pack(JarInputStream in, OutputStream out) throws IOException {
    assert (Utils.currentInstance.get() == null);
    boolean needUTC = !props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE);
    try {
        Utils.currentInstance.set(this);
        if (needUTC) {
            Utils.changeDefaultTimeZoneToUtc();
        }
        if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
            Utils.copyJarFile(in, out);
        } else {
            (new DoPack()).run(in, out);
        }
    } finally {
        Utils.currentInstance.set(null);
        if (needUTC) {
            Utils.restoreDefaultTimeZone();
        }
        in.close();
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:NativeUnpack.java   
private void updateProgress() {
    // Progress is a combination of segment reading and file writing.
    final double READ_WT  = 0.33;
    final double WRITE_WT = 0.67;
    double readProgress = _segCount;
    if (_estByteLimit > 0 && _byteCount > 0)
        readProgress += (double)_byteCount / _estByteLimit;
    double writeProgress = _fileCount;
    double scaledProgress
        = READ_WT  * readProgress  / Math.max(_estSegLimit,1)
        + WRITE_WT * writeProgress / Math.max(_estFileLimit,1);
    int percent = (int) Math.round(100*scaledProgress);
    if (percent > 100)  percent = 100;
    if (percent > _prevPercent) {
        _prevPercent = percent;
        _props.setInteger(Pack200.Unpacker.PROGRESS, percent);
        if (_verbose > 0)
            Utils.log.info("progress = "+percent);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:Utils.java   
static void pack(JarFile jarFile, File packFile) throws IOException {
    Pack200.Packer packer = Pack200.newPacker();
    Map<String, String> p = packer.properties();
    // Take the time optimization vs. space
    p.put(packer.EFFORT, "1");  // CAUTION: do not use 0.
    // Make the memory consumption as effective as possible
    p.put(packer.SEGMENT_LIMIT, "10000");
    // ignore all JAR deflation requests to save time
    p.put(packer.DEFLATE_HINT, packer.FALSE);
    // save the file ordering of the original JAR
    p.put(packer.KEEP_FILE_ORDER, packer.TRUE);
    FileOutputStream fos = null;
    try {
        // Write out to a jtreg scratch area
        fos = new FileOutputStream(packFile);
        // Call the packer
        packer.pack(jarFile, fos);
    } finally {
        close(fos);
    }
}
项目:icedtea-web    文件:ResourceDownloader.java   
private void uncompressPackGz(URL compressedLocation, URL uncompressedLocation, Version version) throws IOException {
    OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Extracting packgz: " + compressedLocation + " to " + uncompressedLocation);

    try (GZIPInputStream gzInputStream = new GZIPInputStream(new FileInputStream(CacheUtil
            .getCacheFile(compressedLocation, version)))) {
        InputStream inputStream = new BufferedInputStream(gzInputStream);

        JarOutputStream outputStream = new JarOutputStream(new FileOutputStream(CacheUtil
                .getCacheFile(uncompressedLocation, version)));

        Pack200.Unpacker unpacker = Pack200.newUnpacker();
        unpacker.unpack(inputStream, outputStream);

        outputStream.close();
        inputStream.close();
    }
}
项目:osm2garmin    文件:Utilities.java   
private void copyLibraries(String library, ThreadProcessor processor) throws URISyntaxException, IOException {
    String userdir = getUserdir(processor);
    String libpath = userdir + "lib/" + library + "/";
    File libfile = new File(libpath);
    libfile.mkdirs();
    String[] listfiles = getResourceListing(Osm2garmin.class, "org/mantlik/osm2garmin/" + library + "/");
    for (String name : listfiles) {
        InputStream stream = Osm2garmin.class.getResourceAsStream(library + "/" + name);
        if (!name.equals("")) {
            if (name.endsWith("pack.gz")) {
                String jarname = name.replace("pack.gz", "jar");
                InputStream input = new GZIPInputStream(stream);
                Pack200.Unpacker unpacker = Pack200.newUnpacker();
                JarOutputStream jo = new JarOutputStream(new FileOutputStream(libpath + jarname));
                unpacker.unpack(input, jo);
                jo.close();
            } else {
                copyFile(stream, new File(libpath + name));
            }
        }
    }
}
项目:infobip-open-jdk-8    文件:PackerImpl.java   
/**
 * Takes a JarFile and converts into a pack-stream.
 * <p>
 * Closes its input but not its output.  (Pack200 archives are appendable.)
 * @param in a JarFile
 * @param out an OutputStream
 * @exception IOException if an error is encountered.
 */
public synchronized void pack(JarFile in, OutputStream out) throws IOException {
    assert(Utils.currentInstance.get() == null);
    TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE))
                  ? null
                  : TimeZone.getDefault();
    try {
        Utils.currentInstance.set(this);
        if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

        if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
            Utils.copyJarFile(in, out);
        } else {
            (new DoPack()).run(in, out);
        }
    } finally {
        Utils.currentInstance.set(null);
        if (tz != null) TimeZone.setDefault(tz);
        in.close();
    }
}
项目:infobip-open-jdk-8    文件:PackerImpl.java   
/**
 * Takes a JarInputStream and converts into a pack-stream.
 * <p>
 * Closes its input but not its output.  (Pack200 archives are appendable.)
 * <p>
 * The modification time and deflation hint attributes are not available,
 * for the jar-manifest file and the directory containing the file.
 *
 * @see #MODIFICATION_TIME
 * @see #DEFLATION_HINT
 * @param in a JarInputStream
 * @param out an OutputStream
 * @exception IOException if an error is encountered.
 */
public synchronized void pack(JarInputStream in, OutputStream out) throws IOException {
    assert(Utils.currentInstance.get() == null);
    TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)) ? null :
        TimeZone.getDefault();
    try {
        Utils.currentInstance.set(this);
        if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
        if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
            Utils.copyJarFile(in, out);
        } else {
            (new DoPack()).run(in, out);
        }
    } finally {
        Utils.currentInstance.set(null);
        if (tz != null) TimeZone.setDefault(tz);
        in.close();
    }
}
项目:infobip-open-jdk-8    文件:NativeUnpack.java   
private void updateProgress() {
    // Progress is a combination of segment reading and file writing.
    final double READ_WT  = 0.33;
    final double WRITE_WT = 0.67;
    double readProgress = _segCount;
    if (_estByteLimit > 0 && _byteCount > 0)
        readProgress += (double)_byteCount / _estByteLimit;
    double writeProgress = _fileCount;
    double scaledProgress
        = READ_WT  * readProgress  / Math.max(_estSegLimit,1)
        + WRITE_WT * writeProgress / Math.max(_estFileLimit,1);
    int percent = (int) Math.round(100*scaledProgress);
    if (percent > 100)  percent = 100;
    if (percent > _prevPercent) {
        _prevPercent = percent;
        _props.setInteger(Pack200.Unpacker.PROGRESS, percent);
        if (_verbose > 0)
            Utils.log.info("progress = "+percent);
    }
}
项目:infobip-open-jdk-8    文件:Utils.java   
static void pack(JarFile jarFile, File packFile) throws IOException {
    Pack200.Packer packer = Pack200.newPacker();
    Map<String, String> p = packer.properties();
    // Take the time optimization vs. space
    p.put(packer.EFFORT, "1");  // CAUTION: do not use 0.
    // Make the memory consumption as effective as possible
    p.put(packer.SEGMENT_LIMIT, "10000");
    // ignore all JAR deflation requests to save time
    p.put(packer.DEFLATE_HINT, packer.FALSE);
    // save the file ordering of the original JAR
    p.put(packer.KEEP_FILE_ORDER, packer.TRUE);
    FileOutputStream fos = null;
    try {
        // Write out to a jtreg scratch area
        fos = new FileOutputStream(packFile);
        // Call the packer
        packer.pack(jarFile, fos);
    } finally {
        close(fos);
    }
}
项目:jdk8u-dev-jdk    文件:PackerImpl.java   
/**
 * Takes a JarFile and converts into a pack-stream.
 * <p>
 * Closes its input but not its output.  (Pack200 archives are appendable.)
 * @param in a JarFile
 * @param out an OutputStream
 * @exception IOException if an error is encountered.
 */
public synchronized void pack(JarFile in, OutputStream out) throws IOException {
    assert(Utils.currentInstance.get() == null);
    TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE))
                  ? null
                  : TimeZone.getDefault();
    try {
        Utils.currentInstance.set(this);
        if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

        if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
            Utils.copyJarFile(in, out);
        } else {
            (new DoPack()).run(in, out);
        }
    } finally {
        Utils.currentInstance.set(null);
        if (tz != null) TimeZone.setDefault(tz);
        in.close();
    }
}
项目:jdk8u-dev-jdk    文件:PackerImpl.java   
/**
 * Takes a JarInputStream and converts into a pack-stream.
 * <p>
 * Closes its input but not its output.  (Pack200 archives are appendable.)
 * <p>
 * The modification time and deflation hint attributes are not available,
 * for the jar-manifest file and the directory containing the file.
 *
 * @see #MODIFICATION_TIME
 * @see #DEFLATION_HINT
 * @param in a JarInputStream
 * @param out an OutputStream
 * @exception IOException if an error is encountered.
 */
public synchronized void pack(JarInputStream in, OutputStream out) throws IOException {
    assert(Utils.currentInstance.get() == null);
    TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)) ? null :
        TimeZone.getDefault();
    try {
        Utils.currentInstance.set(this);
        if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
        if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
            Utils.copyJarFile(in, out);
        } else {
            (new DoPack()).run(in, out);
        }
    } finally {
        Utils.currentInstance.set(null);
        if (tz != null) TimeZone.setDefault(tz);
        in.close();
    }
}
项目:jdk8u-dev-jdk    文件:NativeUnpack.java   
private void updateProgress() {
    // Progress is a combination of segment reading and file writing.
    final double READ_WT  = 0.33;
    final double WRITE_WT = 0.67;
    double readProgress = _segCount;
    if (_estByteLimit > 0 && _byteCount > 0)
        readProgress += (double)_byteCount / _estByteLimit;
    double writeProgress = _fileCount;
    double scaledProgress
        = READ_WT  * readProgress  / Math.max(_estSegLimit,1)
        + WRITE_WT * writeProgress / Math.max(_estFileLimit,1);
    int percent = (int) Math.round(100*scaledProgress);
    if (percent > 100)  percent = 100;
    if (percent > _prevPercent) {
        _prevPercent = percent;
        _props.setInteger(Pack200.Unpacker.PROGRESS, percent);
        if (_verbose > 0)
            Utils.log.info("progress = "+percent);
    }
}
项目:jdk8u-dev-jdk    文件:Utils.java   
static void pack(JarFile jarFile, File packFile) throws IOException {
    Pack200.Packer packer = Pack200.newPacker();
    Map<String, String> p = packer.properties();
    // Take the time optimization vs. space
    p.put(packer.EFFORT, "1");  // CAUTION: do not use 0.
    // Make the memory consumption as effective as possible
    p.put(packer.SEGMENT_LIMIT, "10000");
    // ignore all JAR deflation requests to save time
    p.put(packer.DEFLATE_HINT, packer.FALSE);
    // save the file ordering of the original JAR
    p.put(packer.KEEP_FILE_ORDER, packer.TRUE);
    FileOutputStream fos = null;
    try {
        // Write out to a jtreg scratch area
        fos = new FileOutputStream(packFile);
        // Call the packer
        packer.pack(jarFile, fos);
    } finally {
        close(fos);
    }
}
项目:Lucee    文件:Pack200Util.java   
public static void pack2Jar(InputStream is,OutputStream os, boolean closeIS, boolean closeOS) throws IOException {

    Unpacker unpacker = Pack200.newUnpacker();


    SortedMap<String, String> p = unpacker.properties();
    p.put(Unpacker.DEFLATE_HINT, Unpacker.TRUE);


    is=new GZIPInputStream(is);
    JarOutputStream jos=null;
    try{
        jos = new JarOutputStream(os);
        unpacker.unpack(is, jos);
        jos.finish();
    }
    finally{

        if(closeIS)Util.closeEL(is);
        if(closeOS)Util.closeEL(jos);
    }
}
项目:Lucee    文件:Pack200Util.java   
public static void pack2Jar(InputStream is,OutputStream os, boolean closeIS, boolean closeOS) throws IOException {

    Unpacker unpacker = Pack200.newUnpacker();


    SortedMap<String, String> p = unpacker.properties();
    p.put(Unpacker.DEFLATE_HINT, Unpacker.TRUE);


    is=new GZIPInputStream(is);
    JarOutputStream jos=null;
    try{
        jos = new JarOutputStream(os);
        unpacker.unpack(is, jos);
        jos.finish();
    }
    finally{

        if(closeIS)IOUtil.closeEL(is);
        if(closeOS)IOUtil.closeEL(jos);
    }
}
项目:jdk7-jdk    文件:PackerImpl.java   
/**
 * Takes a JarFile and converts into a pack-stream.
 * <p>
 * Closes its input but not its output.  (Pack200 archives are appendable.)
 * @param in a JarFile
 * @param out an OutputStream
 * @exception IOException if an error is encountered.
 */
public void pack(JarFile in, OutputStream out) throws IOException {
    assert(Utils.currentInstance.get() == null);
    TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE))
                  ? null
                  : TimeZone.getDefault();
    try {
        Utils.currentInstance.set(this);
        if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

        if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
            Utils.copyJarFile(in, out);
        } else {
            (new DoPack()).run(in, out);
        }
    } finally {
        Utils.currentInstance.set(null);
        if (tz != null) TimeZone.setDefault(tz);
        in.close();
    }
}
项目:jdk7-jdk    文件:PackerImpl.java   
/**
 * Takes a JarInputStream and converts into a pack-stream.
 * <p>
 * Closes its input but not its output.  (Pack200 archives are appendable.)
 * <p>
 * The modification time and deflation hint attributes are not available,
 * for the jar-manifest file and the directory containing the file.
 *
 * @see #MODIFICATION_TIME
 * @see #DEFLATION_HINT
 * @param in a JarInputStream
 * @param out an OutputStream
 * @exception IOException if an error is encountered.
 */
public void pack(JarInputStream in, OutputStream out) throws IOException {
    assert(Utils.currentInstance.get() == null);
    TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)) ? null :
        TimeZone.getDefault();
    try {
        Utils.currentInstance.set(this);
        if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
        if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
            Utils.copyJarFile(in, out);
        } else {
            (new DoPack()).run(in, out);
        }
    } finally {
        Utils.currentInstance.set(null);
        if (tz != null) TimeZone.setDefault(tz);
        in.close();
    }
}
项目:jdk7-jdk    文件:NativeUnpack.java   
private void updateProgress() {
    // Progress is a combination of segment reading and file writing.
    final double READ_WT  = 0.33;
    final double WRITE_WT = 0.67;
    double readProgress = _segCount;
    if (_estByteLimit > 0 && _byteCount > 0)
        readProgress += (double)_byteCount / _estByteLimit;
    double writeProgress = _fileCount;
    double scaledProgress
        = READ_WT  * readProgress  / Math.max(_estSegLimit,1)
        + WRITE_WT * writeProgress / Math.max(_estFileLimit,1);
    int percent = (int) Math.round(100*scaledProgress);
    if (percent > 100)  percent = 100;
    if (percent > _prevPercent) {
        _prevPercent = percent;
        _props.setInteger(Pack200.Unpacker.PROGRESS, percent);
        if (_verbose > 0)
            Utils.log.info("progress = "+percent);
    }
}
项目:jdk7-jdk    文件:Utils.java   
static void pack(JarFile jarFile, File packFile) throws IOException {
    Pack200.Packer packer = Pack200.newPacker();
    Map<String, String> p = packer.properties();
    // Take the time optimization vs. space
    p.put(packer.EFFORT, "1");  // CAUTION: do not use 0.
    // Make the memory consumption as effective as possible
    p.put(packer.SEGMENT_LIMIT, "10000");
    // ignore all JAR deflation requests to save time
    p.put(packer.DEFLATE_HINT, packer.FALSE);
    // save the file ordering of the original JAR
    p.put(packer.KEEP_FILE_ORDER, packer.TRUE);
    FileOutputStream fos = null;
    try {
        // Write out to a jtreg scratch area
        fos = new FileOutputStream(packFile);
        // Call the packer
        packer.pack(jarFile, fos);
    } finally {
        close(fos);
    }
}
项目:Wolf_game    文件:AppletLoader.java   
/**
 *  Extract Pack File
 *  @param in Input path to pack file
 *  @param out output path to resulting file
 *  @throws Exception if any errors occur
 */
protected void extractPack(String in, String out) throws Exception {
    File f = new File(in);
    FileOutputStream fostream = new FileOutputStream(out);
    JarOutputStream jostream = new JarOutputStream(fostream);

    try {
        Pack200.Unpacker unpacker = Pack200.newUnpacker();
        unpacker.unpack(f, jostream);
    } finally {
        jostream.close();
        fostream.close();
    }

    // delete pack file as its no longer needed
    f.delete();
}
项目:openjdk-source-code-learn    文件:PackerImpl.java   
/**
 * Takes a JarFile and converts into a pack-stream.
 * <p>
 * Closes its input but not its output.  (Pack200 archives are appendable.)
 * @param in a JarFile
 * @param out an OutputStream
 * @exception IOException if an error is encountered.
 */
public void pack(JarFile in, OutputStream out) throws IOException {
    assert(Utils.currentInstance.get() == null);
    TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE))
                  ? null
                  : TimeZone.getDefault();
    try {
        Utils.currentInstance.set(this);
        if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

        if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
            Utils.copyJarFile(in, out);
        } else {
            (new DoPack()).run(in, out);
        }
    } finally {
        Utils.currentInstance.set(null);
        if (tz != null) TimeZone.setDefault(tz);
        in.close();
    }
}
项目:openjdk-source-code-learn    文件:PackerImpl.java   
/**
 * Takes a JarInputStream and converts into a pack-stream.
 * <p>
 * Closes its input but not its output.  (Pack200 archives are appendable.)
 * <p>
 * The modification time and deflation hint attributes are not available,
 * for the jar-manifest file and the directory containing the file.
 *
 * @see #MODIFICATION_TIME
 * @see #DEFLATION_HINT
 * @param in a JarInputStream
 * @param out an OutputStream
 * @exception IOException if an error is encountered.
 */
public void pack(JarInputStream in, OutputStream out) throws IOException {
    assert(Utils.currentInstance.get() == null);
    TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)) ? null :
        TimeZone.getDefault();
    try {
        Utils.currentInstance.set(this);
        if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
        if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
            Utils.copyJarFile(in, out);
        } else {
            (new DoPack()).run(in, out);
        }
    } finally {
        Utils.currentInstance.set(null);
        if (tz != null) TimeZone.setDefault(tz);
        in.close();
    }
}
项目:openjdk-source-code-learn    文件:NativeUnpack.java   
private void updateProgress() {
    // Progress is a combination of segment reading and file writing.
    final double READ_WT  = 0.33;
    final double WRITE_WT = 0.67;
    double readProgress = _segCount;
    if (_estByteLimit > 0 && _byteCount > 0)
        readProgress += (double)_byteCount / _estByteLimit;
    double writeProgress = _fileCount;
    double scaledProgress
        = READ_WT  * readProgress  / Math.max(_estSegLimit,1)
        + WRITE_WT * writeProgress / Math.max(_estFileLimit,1);
    int percent = (int) Math.round(100*scaledProgress);
    if (percent > 100)  percent = 100;
    if (percent > _prevPercent) {
        _prevPercent = percent;
        _props.setInteger(Pack200.Unpacker.PROGRESS, percent);
        if (_verbose > 0)
            Utils.log.info("progress = "+percent);
    }
}