Stay organized with collections
Save and categorize content based on your preferences.
JarOutputStream
open class JarOutputStream : ZipOutputStream
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.
Summary
| Inherited constants |
From class ZipOutputStream
Int |
CENATT
Central directory (CEN) header internal file attributes field offset.
|
Int |
CENATX
Central directory (CEN) header external file attributes field offset.
|
Int |
CENCOM
Central directory (CEN) header comment length field offset.
|
Int |
CENCRC
Central directory (CEN) header uncompressed file crc-32 value field offset.
|
Int |
CENDSK
Central directory (CEN) header disk number start field offset.
|
Int |
CENEXT
Central directory (CEN) header extra field length field offset.
|
Int |
CENFLG
Central directory (CEN) header encrypt, decrypt flags field offset.
|
Int |
CENHDR
Central directory (CEN) header size in bytes (including signature).
|
Int |
CENHOW
Central directory (CEN) header compression method field offset.
|
Int |
CENLEN
Central directory (CEN) header uncompressed size field offset.
|
Int |
CENNAM
Central directory (CEN) header filename length field offset.
|
Int |
CENOFF
Central directory (CEN) header LOC header offset field offset.
|
Long |
CENSIG
Central directory (CEN) header signature.
|
Int |
CENSIZ
Central directory (CEN) header compressed size field offset.
|
Int |
CENTIM
Central directory (CEN) header modification time field offset.
|
Int |
CENVEM
Central directory (CEN) header version made by field offset.
|
Int |
CENVER
Central directory (CEN) header version needed to extract field offset.
|
Int |
DEFLATED
Compression method for compressed (DEFLATED) entries.
|
Int |
ENDCOM
End of central directory (END) header zip file comment length field offset.
|
Int |
ENDHDR
End of central directory (END) header size in bytes (including signature).
|
Int |
ENDOFF
End of central directory (END) header offset for the first CEN header field offset.
|
Long |
ENDSIG
End of central directory (END) header signature.
|
Int |
ENDSIZ
End of central directory (END) header central directory size in bytes field offset.
|
Int |
ENDSUB
End of central directory (END) header number of entries on this disk field offset.
|
Int |
ENDTOT
End of central directory (END) header total number of entries field offset.
|
Int |
EXTCRC
Extra local (EXT) header uncompressed file crc-32 value field offset.
|
Int |
EXTHDR
Extra local (EXT) header size in bytes (including signature).
|
Int |
EXTLEN
Extra local (EXT) header uncompressed size field offset.
|
Long |
EXTSIG
Extra local (EXT) header signature.
|
Int |
EXTSIZ
Extra local (EXT) header compressed size field offset.
|
Int |
LOCCRC
Local file (LOC) header uncompressed file crc-32 value field offset.
|
Int |
LOCEXT
Local file (LOC) header extra field length field offset.
|
Int |
LOCFLG
Local file (LOC) header general purpose bit flag field offset.
|
Int |
LOCHDR
Local file (LOC) header size in bytes (including signature).
|
Int |
LOCHOW
Local file (LOC) header compression method field offset.
|
Int |
LOCLEN
Local file (LOC) header uncompressed size field offset.
|
Int |
LOCNAM
Local file (LOC) header filename length field offset.
|
Long |
LOCSIG
Local file (LOC) header signature.
|
Int |
LOCSIZ
Local file (LOC) header compressed size field offset.
|
Int |
LOCTIM
Local file (LOC) header modification time field offset.
|
Int |
LOCVER
Local file (LOC) header version needed to extract field offset.
|
Int |
STORED
Compression method for uncompressed (STORED) entries.
|
|
| Public constructors |
|
Creates a new JarOutputStream with no manifest.
|
|
Creates a new JarOutputStream with the specified Manifest.
|
| Public methods |
| open Unit |
Begins writing a new JAR file entry and positions the stream to the start of the entry data.
|
| Inherited functions |
From class ZipOutputStream
Unit |
close()
Closes the ZIP output stream as well as the stream being filtered.
|
Unit |
closeEntry()
Closes the current ZIP entry and positions the stream for writing the next entry.
|
Unit |
finish()
Finishes writing the contents of the ZIP output stream without closing the underlying stream. Use this method when applying multiple filters in succession to the same output stream.
|
Unit |
setComment(: String!)
Sets the ZIP file comment.
|
Unit |
setLevel(level: Int)
Sets the compression level for subsequent entries which are DEFLATED. The default setting is DEFAULT_COMPRESSION.
|
Unit |
setMethod(method: Int)
Sets the default compression method for subsequent entries. This default will be used whenever the compression method is not specified for an individual ZIP file entry, and is initially set to DEFLATED.
|
Unit |
write(b: ByteArray!, off: Int, len: Int)
Writes an array of bytes to the current ZIP entry data. This method will block until all the bytes are written.
|
|
From class DeflaterOutputStream
Unit |
deflate()
Writes next block of compressed data to the output stream.
|
Unit |
flush()
Flushes the compressed output stream. If syncFlush is true when this compressed output stream is constructed, this method first flushes the underlying compressor with the flush mode Deflater.SYNC_FLUSH to force all pending data to be flushed out to the output stream and then flushes the output stream. Otherwise this method only flushes the output stream without flushing the compressor.
|
Unit |
write(b: Int)
Writes a byte to the compressed output stream. This method will block until the byte can be written.
|
|
From class OutputStream
OutputStream! |
nullOutputStream()
Returns a new OutputStream which discards all bytes. The returned stream is initially open. The stream is closed by calling the close() method. Subsequent calls to close() have no effect.
While the stream is open, the write(int), write(byte[]), and write(byte[], int, int) methods do nothing. After the stream has been closed, these methods all throw IOException.
The flush() method does nothing.
|
|
From class FilterOutputStream
Unit |
write(b: ByteArray!)
Writes b.length bytes to this output stream.
The write method of FilterOutputStream calls its write method of three arguments with the arguments b, 0, and b.length.
Note that this method does not call the one-argument write method of its underlying output stream with the single argument b.
|
|
Public constructors
JarOutputStream
JarOutputStream(out: OutputStream!)
Creates a new JarOutputStream with no manifest.
| Exceptions |
java.io.IOException |
if an I/O error has occurred |
JarOutputStream
JarOutputStream(
out: OutputStream!,
man: Manifest!)
Creates a new JarOutputStream with the specified Manifest. The manifest is written as the first entry to the output stream.
| Exceptions |
java.io.IOException |
if an I/O error has occurred |
Public methods
putNextEntry
open fun putNextEntry(ze: ZipEntry!): Unit
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. The current time will be used if the entry has no set modification time.
| Parameters |
e |
the ZIP entry to be written |
ze |
ZipEntry!: the ZIP/JAR entry to be written |
| Exceptions |
java.io.IOException |
if an I/O error has occurred |
java.util.zip.ZipException |
if a ZIP error has occurred |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2026-06-23 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-06-23 UTC."],[],[]]