Name
JarOutputStream
Synopsis
This
class can write a JAR file to an arbitrary
OutputStream
. JarOutputStream
extends java.util.zip.ZipOutputStream
and is used
much like that class is used. Create a
JarOutputStream
by specifying the stream to write
to and, optionally, the Manifest
object for the
JAR file. The JarOutputStream( )
constructor
starts by writing the contents of the Manifest
object into an appropriate JAR file entry. It is the
programmer’s responsibility to ensure that the
contents of the JAR entries written subsequently match those
specified in the Manifest
object. This class
provides no explicit support for attaching digital signatures to
entries in the JAR file.
After creating a
JarOutputStream
, call putNextEntry(
)
to specify the JarEntry
or
java.util.zip.ZipEntry
to be written to the
stream. Then, call any of the inherited write( )
methods to write the contents of the entry to the stream. When that
entry is finished, call putNextEntry( )
again to
begin writing the next entry. When you have written all JAR file
entries in this way, call close( )
. Before writing
any entry, you may call the inherited setMethod( )
and setLevel( )
methods to specify how the entry
should be compressed. See
java.util.zip.ZipOutputStream
.
Figure 16-112. java.util.jar.JarOutputStream
public class JarOutputStream extends java.util.zip.ZipOutputStream { // Public Constructors public JarOutputStream ...
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.