How do you programmatically create a JAR file?
Created Feb 27, 2002
Heinrich Soebke
File outFile = new File(outPath);
BufferedOutputStream bo = new BufferedOutputStream(new FileOutputStream(outPath));
JarOutputStream jo = new JarOutputStream(bo);
String act = f.getPath();
BufferedInputStream bi = new BufferedInputStream(new FileInputStream(act));
JarEntry je = new JarEntry(act);
jo.putNextEntry(je);
byte[] buf = new byte[1024];
int anz;
while ((anz = bi.read(buf)) != -1) {
jo.write(buf, 0, anz);
}
bi.close();
jo.close();
bo.close();
See also http://developer.java.sun.com/developer/technicalArticles/Programming/compression/.