/* Class : JarOutputStream

  Implementation of the 1.2 Java class JarOutputStream.

  Copyright : Moses DeJong, dejong@cs.umn.edu, 1998.
  Source code licensed under the GPL.
  You can get a copy of the license from www.gnu.org.

  This code is intended for use in the Kaffe project but you can use
  it in other projects as long as you follow the license rules.
*/

package java.util.jar;

import java.io.*;
import java.util.zip.*;

public class JarOutputStream extends ZipOutputStream
{
    public JarOutputStream(OutputStream out, Manifest man) throws IOException
    {
	super(out);
	if (man != null) {
	    ZipEntry ze = new ZipEntry(JarFile.MANIFEST_NAME);
	    ze.setMethod(ZipEntry.DEFLATED); // compressed entry
	    putNextEntry(ze);
	    man.write(out);
	    closeEntry();
	}
    }

    public JarOutputStream(OutputStream out) throws IOException
    {
	super(out);
    }

    public void putNextEntry(ZipEntry ze) throws IOException
    {
	// FIXME : this method must be overridden for some reason.
	// It must do something extra that super.putNextEntry() does not.

	// so far I have been able to figure out that JarOutputStream
	// will use the ZipEntry.setExtra() method to add 4 bytes
	// of data. I have no idea what this data is but it seems to
	// be the same for both uncompressed and compressed archives.

	byte[] data = {-2,-54,0,0};
	ze.setExtra(data);

	super.putNextEntry(ze);
    }
}


@@ -484,15 +484,17 @@
 ream
+ %7B
 %0A
-%7B
 %0A    
+%09
 publ
@@ -542,18 +542,26 @@
 fest man
-) 
+ifest)%0A%09%09%09
 throws I
@@ -562,39 +562,36 @@
 rows IOException
-%0A   
  %7B%0A
+%09
 %09super(out);%0A%09if
@@ -591,16 +591,17 @@
 t);%0A
+%09
 %09if (man
  != 
@@ -600,10 +600,15 @@
 (man
- !
+ifest =
 = nu
@@ -618,33 +618,46 @@
  %7B%0A%09
-    Zip
+%09%09return;%0A%09%09%7D%0A%09%09Jar
 Entry 
-z
 e
+nt
  = new 
-Zip
+Jar
 Entr
@@ -687,70 +687,9 @@
 );%0A%09
-    ze.setMethod(ZipEntry.DEFLATED); // compressed entry%0A%09    
+%09
 putN
@@ -701,646 +701,550 @@
 try(
-z
 e
+nt
 );%0A%09
-    man.write(out);%0A%09    closeEntry();%0A%09%7D%0A    %7D%0A%0A    public JarOutputStream(OutputStream out) throws IOException%0A    %7B%0A%09super(out);%0A    %7D%0A%0A    public void putNextEntry(ZipEntry ze) throws IOException%0A    %7B%0A%09// FIXME : this method must be overridden for some reason.%0A%09// It must do something extra that super.putNextEntry() does not.%0A%0A%09// so far I have been able to figure out that JarOutputStream%0A%09// will use the ZipEntry.setExtra() method to add 4 bytes%0A%09// of data. I have no idea what this data is but it seems to%0A%09// be the same for both uncompressed and compressed archives.%0A%0A%09byte%5B%5D data = %7B-2,-54,0,0%7D;%0A%09ze.setExtra(data);%0A%0A
+%09manifest.write(new OutputStream() %7B%0A%09%09%09public void write(int b) throws IOException %7B%0A%09%09%09%09JarOutputStream.this.write(b);%0A%09%09%09%7D%0A%09%09%09public void write(byte%5B%5D buf, int off, int len)%0A%09%09%09%09%09throws IOException %7B%0A%09%09%09%09JarOutputStream.this.write(buf, off, len);%0A%09%09%09%7D%0A%09%09%09public void flush() throws IOException %7B%0A%09%09%09%09JarOutputStream.this.flush();%0A%09%09%09%7D%0A%09%09%7D);%0A%09%09closeEntry();%0A%09%7D%0A%0A%09public JarOutputStream(OutputStream out) throws IOException %7B%0A%09%09super(out);%0A%09%7D%0A%0A%09// Why is this method here?%0A%09public void putNextEntry(ZipEntry ze) throws IOException %7B%0A%09
 %09sup
@@ -1264,17 +1264,14 @@
 ry(ze);%0A
-    
+%09
 %7D%0A%7D%0A%0A

Fix bug in writing out the Manifest to the JAR file.