List of usage examples for java.util.jar Pack200 newUnpacker
public static Unpacker newUnpacker()
From source file:Main.java
public static void main(String[] args) throws Exception { Pack200.Unpacker unpacker = Pack200.newUnpacker(); JarOutputStream out = new JarOutputStream(new FileOutputStream("outName")); InputStream in = new FileInputStream("inName"); // in = new GZIPInputStream(in); unpacker.unpack(in, out);/*from w w w . j a v a 2 s . co m*/ out.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { String inName = "a.pack.gz"; String outName = "a.unpacked"; Pack200.Unpacker unpacker = Pack200.newUnpacker(); JarOutputStream out = new JarOutputStream(new FileOutputStream(outName)); InputStream in = new FileInputStream(inName); in = new GZIPInputStream(in); unpacker.unpack(in, out);//from ww w . jav a 2s . c o m out.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { String inName = "abc.pack.gz"; String outName = "abc"; Pack200.Unpacker unpacker = Pack200.newUnpacker(); JarOutputStream out = new JarOutputStream(new FileOutputStream(outName)); InputStream in = new FileInputStream(inName); if (inName.endsWith(".gz")) { in = new GZIPInputStream(in); }// www . j av a 2 s . c om unpacker.unpack(in, out); out.close(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { String inName = args[0];//from w w w . ja v a 2 s .com String outName; if (inName.endsWith(".pack.gz")) { outName = inName.substring(0, inName.length() - 8); } else if (inName.endsWith(".pack")) { outName = inName.substring(0, inName.length() - 5); } else { outName = inName + ".unpacked"; } JarOutputStream out = null; InputStream in = null; Pack200.Unpacker unpacker = Pack200.newUnpacker(); out = new JarOutputStream(new FileOutputStream(outName)); in = new FileInputStream(inName); if (inName.endsWith(".gz")) in = new GZIPInputStream(in); unpacker.unpack(in, out); out.close(); }
From source file:com.izforge.izpack.installer.unpacker.Pack200FileUnpacker.java
private Pack200.Unpacker createPack200Unpacker(PackFile packFile) { Pack200.Unpacker unpacker = Pack200.newUnpacker(); Map<String, String> defaultUnpackerProperties = unpacker.properties(); Map<String, String> localPackerProperties = packFile.getPack200Properties(); if (localPackerProperties != null) { defaultUnpackerProperties.putAll(localPackerProperties); }//from w w w. java 2s. co m return unpacker; }
From source file:ch.randelshofer.cubetwister.HTMLExporter.java
/** * Processes a pack200 template, by writing it both as a pack200 file and * a Jar file to the output stream.//from ww w . j a v a 2s .co m * * @param filename The name of the template. Must end with ".jar.pack.gz". * @param in An input stream for reading the contents of the template. */ private void processPack200Template(String filename, InputStream in) throws IOException { p.setNote("Exporting " + filename + " ..."); p.setProgress(p.getProgress() + 1); // Determine whether we can skip this file boolean skip = true; int pos1 = filename.lastIndexOf('/'); int pos2 = filename.lastIndexOf("Player.jar.pack.gz"); if (pos2 != -1) { for (CubeKind ck : playerCubeKinds) { if (ck.isNameOfKind(filename.substring(pos1 + 1, pos2))) { skip = false; break; } } if (skip) for (CubeKind ck : virtualCubeKinds) { if (ck.isNameOfKind(filename.substring(pos1 + 1, pos2))) { skip = false; break; } } } if (skip) { pos1 = filename.lastIndexOf("Virtual"); pos2 = filename.lastIndexOf(".jar.pack.gz"); if (pos2 != -1) { for (CubeKind ck : virtualCubeKinds) { if (ck.isNameOfKind(filename.substring(pos1 + 7, pos2))) { skip = false; break; } } } } if (skip) { return; } byte[] buf = new byte[1024]; int len; // Write the pack200 file into the output and into a temporary buffer putNextEntry(filename); ByteArrayOutputStream tmp = new ByteArrayOutputStream(); while (-1 != (len = in.read(buf, 0, buf.length))) { tmp.write(buf, 0, len); entryOut.write(buf, 0, len); } closeEntry(); tmp.close(); // Uncompress the pack200 file from the temporary buffer into the output putNextEntry(filename.substring(0, filename.length() - 8)); InputStream itmp = new GZIPInputStream(new ByteArrayInputStream(tmp.toByteArray())); JarOutputStream jout = new JarOutputStream(entryOut); jout.setLevel(Deflater.BEST_COMPRESSION); Unpacker unpacker = Pack200.newUnpacker(); unpacker.unpack(itmp, jout); jout.finish(); closeEntry(); }