當前位置: 首頁>>代碼示例>>Java>>正文


Java Pack200.newUnpacker方法代碼示例

本文整理匯總了Java中java.util.jar.Pack200.newUnpacker方法的典型用法代碼示例。如果您正苦於以下問題:Java Pack200.newUnpacker方法的具體用法?Java Pack200.newUnpacker怎麽用?Java Pack200.newUnpacker使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.jar.Pack200的用法示例。


在下文中一共展示了Pack200.newUnpacker方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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();
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:23,代碼來源:AppletLoader.java

示例2: 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();
    }
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:21,代碼來源:PackLoader.java

示例3: 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();
    }
}
 
開發者ID:GITNE,項目名稱:icedtea-web,代碼行數:18,代碼來源:ResourceDownloader.java

示例4: 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));
            }
        }
    }
}
 
開發者ID:mantlik,項目名稱:osm2garmin,代碼行數:23,代碼來源:Utilities.java

示例5: 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);
	}
}
 
開發者ID:lucee,項目名稱:Lucee,代碼行數:23,代碼來源:Pack200Util.java

示例6: 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);
	}
}
 
開發者ID:lucee,項目名稱:Lucee,代碼行數:23,代碼來源:Pack200Util.java

示例7: unpackPacked200Jar

import java.util.jar.Pack200; //導入方法依賴的package包/類
/**
 * Unpacks a pack200 packed jar file from {@code packedJar} into {@code target}. If {@code
 * packedJar} has a {@code .gz} extension, it will be gunzipped first.
 */
public static void unpackPacked200Jar (File packedJar, File target) throws IOException
{
    InputStream packedJarIn = null;
    FileOutputStream extractedJarFileOut = null;
    JarOutputStream jarOutputStream = null;
    try {
        extractedJarFileOut = new FileOutputStream(target);
        jarOutputStream = new JarOutputStream(extractedJarFileOut);
        packedJarIn = new FileInputStream(packedJar);
        if (packedJar.getName().endsWith(".gz")) {
            packedJarIn = new GZIPInputStream(packedJarIn);
        }
        Pack200.Unpacker unpacker = Pack200.newUnpacker();
        unpacker.unpack(packedJarIn, jarOutputStream);

    } finally {
        StreamUtil.close(jarOutputStream);
        StreamUtil.close(extractedJarFileOut);
        StreamUtil.close(packedJarIn);
    }
}
 
開發者ID:threerings,項目名稱:getdown,代碼行數:26,代碼來源:FileUtil.java

示例8: verify6991164

import java.util.jar.Pack200; //導入方法依賴的package包/類
static void verify6991164() {
    Unpacker unpacker = Pack200.newUnpacker();
    String versionStr = unpacker.toString();
    String expected = "Pack200, Vendor: " +
            System.getProperty("java.vendor") + ", Version: " +
            JAVA7_PACKAGE_MAJOR_VERSION + "." + JAVA7_PACKAGE_MINOR_VERSION;
    if (!versionStr.equals(expected)) {
        System.out.println("Expected: " + expected);
        System.out.println("Obtained: " + versionStr);
        throw new RuntimeException("did not get expected string " + expected);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:13,代碼來源:PackageVersionTest.java

示例9: unpack0

import java.util.jar.Pack200; //導入方法依賴的package包/類
private static void unpack0(File inFile, JarOutputStream jarStream,
        boolean useJavaUnpack) throws IOException {
    // Unpack the files
    Pack200.Unpacker unpacker = Pack200.newUnpacker();
    Map<String, String> props = unpacker.properties();
    if (useJavaUnpack) {
        props.put("com.sun.java.util.jar.pack.disable.native", "true");
    }
    // Call the unpacker
    unpacker.unpack(inFile, jarStream);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:12,代碼來源:Utils.java

示例10: unpack

import java.util.jar.Pack200; //導入方法依賴的package包/類
@Override
public void unpack( File source, File destination, Map<String, String> props )
        throws IOException
{
    InputStream in = null;
    JarOutputStream out = null;
    try
    {
        in = new FileInputStream( source );
        if ( isGzipped( source ) )
        {
            in = new GZIPInputStream( in );
        }
        in = new BufferedInputStream( in );

        out = new JarOutputStream( new BufferedOutputStream( new FileOutputStream( destination ) ) );

        Pack200.Unpacker unpacker = Pack200.newUnpacker();
        unpacker.properties().putAll( props );
        unpacker.unpack( in, out );
    }
    finally
    {
        IOUtil.close( in );
        IOUtil.close( out );
    }
}
 
開發者ID:mojohaus,項目名稱:webstart,代碼行數:28,代碼來源:DefaultPack200Tool.java

示例11: verify6991164

import java.util.jar.Pack200; //導入方法依賴的package包/類
static void verify6991164() {
    Unpacker unpacker = Pack200.newUnpacker();
    String versionStr = unpacker.toString();
    String expected = "Pack200, Vendor: " +
            System.getProperty("java.vendor") + ", Version: " +
            JAVA6_PACKAGE_MAJOR_VERSION + "." + JAVA6_PACKAGE_MINOR_VERSION;
    if (!versionStr.equals(expected)) {
        System.out.println("Expected: " + expected);
        System.out.println("Obtained: " + versionStr);
        throw new RuntimeException("did not get expected string " + expected);
    }
}
 
開發者ID:openjdk,項目名稱:jdk7-jdk,代碼行數:13,代碼來源:PackageVersionTest.java

示例12: unpack200

import java.util.jar.Pack200; //導入方法依賴的package包/類
public static Application unpack200(File file) throws IOException {
	logger.info("Unpacking pack200 file " + file + "...");
	/* read the .pack200 file into memory and tack on the GZIP header */
	ByteArrayOutputStream out = new ByteArrayOutputStream();
	try {
		out.write(31);
		out.write(-117);

		try (InputStream is = new FileInputStream(file)) {
			for (;;) {
				byte[] buf = new byte[4096];
				int len = is.read(buf);
				if (len == -1)
					break;

				out.write(buf, 0, len);
			}
		}
	} finally {
		out.close();
	}

	/* convert the pack200 file to a temporary jar file */
	File tmp = File.createTempFile("tmp", ".jar");
	JarOutputStream os = new JarOutputStream(new FileOutputStream(tmp));
	try {
		InputStream in = new GZIPInputStream(new ByteArrayInputStream(out.toByteArray()));
		try {
			Pack200.Unpacker unpacker = Pack200.newUnpacker();
			unpacker.unpack(in, os);
		} finally {
			in.close();
		}
	} finally {
		os.close();
	}

	/* unpack the temporary jar file */
	return unpackJar(tmp);
}
 
開發者ID:davidi2,項目名稱:mopar,代碼行數:41,代碼來源:Application.java

示例13: normalize

import java.util.jar.Pack200; //導入方法依賴的package包/類
public static void normalize(File from, File to, Map<String, String> props) throws IOException {
	if (props == null) {
		props = new HashMap();
	}

	((Map) props).put("pack.segment.limit", "-1");
	File f = File.createTempFile("commons-compress", "pack200normalize");
	f.deleteOnExit();

	try {
		Object os = new FileOutputStream(f);
		Object j = null;

		try {
			Pack200.Packer p = Pack200.newPacker();
			p.properties().putAll((Map) props);
			p.pack(new JarFile(from), (OutputStream) os);
			j = null;
			((OutputStream) os).close();
			os = null;
			Pack200.Unpacker u = Pack200.newUnpacker();
			os = new JarOutputStream(new FileOutputStream(to));
			u.unpack(f, (JarOutputStream) os);
		} finally {
			if (j != null) {
				((JarFile) j).close();
			}

			if (os != null) {
				((OutputStream) os).close();
			}

		}
	} finally {
		f.delete();
	}

}
 
開發者ID:krasa,項目名稱:EclipseCodeFormatter,代碼行數:39,代碼來源:RepackJars.java

示例14: getPack200Unpacker

import java.util.jar.Pack200; //導入方法依賴的package包/類
private Pack200.Unpacker getPack200Unpacker()
{
    if (unpacker == null)
    {
        unpacker = Pack200.newUnpacker();
    }
    return unpacker;
}
 
開發者ID:OpenNMS,項目名稱:installer,代碼行數:9,代碼來源:Unpacker.java

示例15: unpack200

import java.util.jar.Pack200; //導入方法依賴的package包/類
private static void unpack200(final File compressedInput, final File decompressedOutput)
        throws FileNotFoundException, IOException {
    if (compressedInput == null) {
        throw new NullPointerException("compressedInput");
    }
    if (decompressedOutput == null) {
        throw new NullPointerException("decompressedOutput");
    }
    try (final FileOutputStream fostream = new FileOutputStream(decompressedOutput)) {
        try (final JarOutputStream jostream = new JarOutputStream(fostream)) {
            final Pack200.Unpacker unpacker = Pack200.newUnpacker();
            unpacker.unpack(compressedInput, jostream);
        }
    }
}
 
開發者ID:fragmer,項目名稱:ClassiCubeLauncher,代碼行數:16,代碼來源:SharedUpdaterCode.java


注:本文中的java.util.jar.Pack200.newUnpacker方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。