本文整理汇总了Java中java.util.jar.Pack200类的典型用法代码示例。如果您正苦于以下问题:Java Pack200类的具体用法?Java Pack200怎么用?Java Pack200使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Pack200类属于java.util.jar包,在下文中一共展示了Pack200类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateProgress
import java.util.jar.Pack200; //导入依赖的package包/类
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);
}
}
示例2: main
import java.util.jar.Pack200; //导入依赖的package包/类
/**
* @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);
}
示例3: pack
import java.util.jar.Pack200; //导入依赖的package包/类
/**
* 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();
}
}
示例4: pack
import java.util.jar.Pack200; //导入依赖的package包/类
/**
* 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();
}
}
示例5: pack
import java.util.jar.Pack200; //导入依赖的package包/类
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);
}
}
示例6: extractPack
import java.util.jar.Pack200; //导入依赖的package包/类
/**
* 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();
}
示例7: run
import java.util.jar.Pack200; //导入依赖的package包/类
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();
}
}
示例8: uncompressPackGz
import java.util.jar.Pack200; //导入依赖的package包/类
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();
}
}
示例9: copyLibraries
import java.util.jar.Pack200; //导入依赖的package包/类
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));
}
}
}
}
示例10: pack2Jar
import java.util.jar.Pack200; //导入依赖的package包/类
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);
}
}
示例11: pack2Jar
import java.util.jar.Pack200; //导入依赖的package包/类
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);
}
}
示例12: pack
import java.util.jar.Pack200; //导入依赖的package包/类
/**
* 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();
}
}