APIdia Launch Partner
Top Description Fields Constructors Methods
java.util.jar

public Class JarOutputStream

extends ZipOutputStream
Class Inheritance
Imports
java.util.zip.*, java.io.*

The JarOutputStream class is used to write the contents of a JAR file to any output stream. It extends the class java.util.zip.ZipOutputStream with support for writing an optional Manifest entry. The Manifest can be used to specify meta-information about the JAR file and its entries.

Unless otherwise noted, passing a null argument to a constructor or method in this class will cause a NullPointerException to be thrown.

Author
David Connelly
Since
1.2
See Also
Manifest, java.util.zip.ZipOutputStream

Field Summary

Modifier and TypeField and Description
private boolean
private static final int
Inherited from java.util.zip.ZipOutputStream:
DEFLATEDSTORED

Constructor Summary

AccessConstructor and Description
public
JarOutputStream(OutputStream
the actual output stream
out
,
Manifest
the optional Manifest
man
)

Creates a new JarOutputStream with the specified Manifest.

public
JarOutputStream(OutputStream
the actual output stream
out
)

Creates a new JarOutputStream with no manifest.

Method Summary

Modifier and TypeMethod and Description
private static int
get16(byte[] b, int off)

private static boolean
hasMagic(byte[] edata)

public void
putNextEntry(ZipEntry
the ZIP/JAR entry to be written
ze
)

Overrides java.util.zip.ZipOutputStream.putNextEntry.

Begins writing a new JAR file entry and positions the stream to the start of the entry data.

private static void
set16(byte[] b, int off, int value)

Inherited from java.util.zip.ZipOutputStream:
closecloseEntryfinishsetCommentsetLevelsetMethodwrite

Field Detail

firstEntryback to summary
private boolean firstEntry
JAR_MAGICback to summary
private static final int JAR_MAGIC

Constructor Detail

JarOutputStreamback to summary
public JarOutputStream(OutputStream out, Manifest man) throws IOException

Creates a new JarOutputStream with the specified Manifest. The manifest is written as the first entry to the output stream.

Parameters
out:OutputStream

the actual output stream

man:Manifest

the optional Manifest

Annotations
@SuppressWarnings:this-escape
Exceptions
IOException:
if an I/O error has occurred
JarOutputStreamback to summary
public JarOutputStream(OutputStream out) throws IOException

Creates a new JarOutputStream with no manifest.

Parameters
out:OutputStream

the actual output stream

Exceptions
IOException:
if an I/O error has occurred

Method Detail

get16back to summary
private static int get16(byte[] b, int off)
hasMagicback to summary
private static boolean hasMagic(byte[] edata)
putNextEntryback to summary
public void putNextEntry(ZipEntry ze) throws IOException

Overrides java.util.zip.ZipOutputStream.putNextEntry.

Begins writing a new JAR file entry and positions the stream to the start of the entry data. This method will also close any previous entry.

The default compression method will be used if no compression method was specified for the entry. When writing a compressed (DEFLATED) entry, and the compressed size has not been explicitly set with the ZipEntry#setCompressedSize(long) method, then the compressed size will be set to the actual compressed size after deflation.

The current time will be used if the entry has no set modification time.

Parameters
ze:ZipEntry

the ZIP/JAR entry to be written

Exceptions
IOException:
if an I/O error has occurred
ZipException:
if a ZIP error has occurred
set16back to summary
private static void set16(byte[] b, int off, int value)