Java Pack200.newUnpacker()

Syntax

Pack200.newUnpacker() has the following syntax.

public static Pack200.Unpacker newUnpacker()

Example

In the following code shows how to use Pack200.newUnpacker() method.


import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.jar.JarOutputStream;
import java.util.jar.Pack200;
import java.util.zip.GZIPInputStream;
/*from w w w. j a  v  a2 s . c  o  m*/
public class Main {

  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);
    }
      
    unpacker.unpack(in, out);
    out.close();
  }
}




















Home »
  Java Tutorial »
    java.util.jar »




JarFile
Pack200