Java by API/java.util.jar/Pack200 — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 17:43, 31 мая 2010
Содержание
PackewPacker()
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.jar.JarFile;
import java.util.jar.Pack200;
public class Main {
public static void main(String[] args) throws Exception {
JarFile f = new JarFile("a.jar");
Pack200.Packer packer = Pack200.newPacker();
OutputStream out = new FileOutputStream("a.pack");
packer.pack(f, out);
out.close();
}
}
PackewUnpacker()
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.jar.JarOutputStream;
import java.util.jar.Pack200;
public class Main {
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);
out.close();
}
}
Pack200.Packer.pack(JarFile in, OutputStream out)
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.jar.JarFile;
import java.util.jar.Pack200;
public class Main {
public static void main(String[] args) throws Exception {
OutputStream out = null;
JarFile f = new JarFile(args[0]);
Pack200.Packer packer = Pack200.newPacker();
out = new FileOutputStream(args[0] + ".pack");
packer.pack(f, out);
out.close();
}
}
Packnpacker.unpack(InputStream in, JarOutputStream out)
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.jar.JarOutputStream;
import java.util.jar.Pack200;
public class Main {
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);
out.close();
}
}