Top Description Fields Constructors Methods
org.apache.commons.compress.archivers.ar

public Class ArArchiveOutputStream

extends ArchiveOutputStream<ArArchiveEntry>
Class Inheritance
Static Imports
java.nio.charset.StandardCharsets.US_ASCII

Implements the "ar" archive format as an output stream.

Field Summary

Modifier and TypeField and Description
private long
private boolean
finished

Indicates if this archive is finished

private boolean
public static final int
LONGFILE_BSD

BSD ar extensions are used to store long file names in the archive.

public static final int
LONGFILE_ERROR

Fail if a long file name is required in the archive.

private int
private final OutputStream
private ArArchiveEntry

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Calls finish if necessary, and then closes the OutputStream
public void
closeArchiveEntry()

Implements abstract org.apache.commons.compress.archivers.ArchiveOutputStream.closeArchiveEntry.

Closes the archive entry, writing any trailer information that may be required.
public ArArchiveEntry
createArchiveEntry(final File
the file to create the entry from
inputFile
,
final String
name to use for the entry
entryName
)

Implements abstract org.apache.commons.compress.archivers.ArchiveOutputStream.createArchiveEntry.

Creates an archive entry using the inputFile and entryName provided.
public ArArchiveEntry
createArchiveEntry(final Path
the file to create the entry from
inputPath
,
final String
name to use for the entry
entryName
,
final LinkOption...
options indicating how symbolic links are handled.
options
)

Overrides org.apache.commons.compress.archivers.ArchiveOutputStream.createArchiveEntry.

Creates an archive entry using the inputPath and entryName provided.
private long
fill(final long pOffset, final long pNewOffset, final char pFill)

public void
finish()

Implements abstract org.apache.commons.compress.archivers.ArchiveOutputStream.finish.

Finishes the addition of entries to this stream, without closing it.
public void
putArchiveEntry(final ArArchiveEntry
describes the entry
entry
)

Implements abstract org.apache.commons.compress.archivers.ArchiveOutputStream.putArchiveEntry.

Writes the headers for an archive entry to the output stream.
public void
setLongFileMode(final int
the mode to use
longFileMode
)

Sets the long file mode.

public void
write(final byte[]
the data.
b
,
final int
the start offset in the data.
off
,
final int
the number of bytes to write.
len
)

Overrides java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.
private long
write(final String data)

private void
private void
Inherited from org.apache.commons.compress.archivers.ArchiveOutputStream:
canWriteEntryDatacountcountgetBytesWrittengetCountwrite

Field Detail

entryOffsetback to summary
private long entryOffset
finishedback to summary
private boolean finished

Indicates if this archive is finished

haveUnclosedEntryback to summary
private boolean haveUnclosedEntry
LONGFILE_BSDback to summary
public static final int LONGFILE_BSD

BSD ar extensions are used to store long file names in the archive.

LONGFILE_ERRORback to summary
public static final int LONGFILE_ERROR

Fail if a long file name is required in the archive.

longFileModeback to summary
private int longFileMode
outback to summary
private final OutputStream out
prevEntryback to summary
private ArArchiveEntry prevEntry

Constructor Detail

ArArchiveOutputStreamback to summary
public ArArchiveOutputStream(final OutputStream out)

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Calls finish if necessary, and then closes the OutputStream

Annotations
@Override
Exceptions
IOException:

Doc from java.io.OutputStream.close.

if an I/O error occurs.

closeArchiveEntryback to summary
public void closeArchiveEntry() throws IOException

Implements abstract org.apache.commons.compress.archivers.ArchiveOutputStream.closeArchiveEntry.

Doc from org.apache.commons.compress.archivers.ArchiveOutputStream.closeArchiveEntry.

Closes the archive entry, writing any trailer information that may be required.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
createArchiveEntryback to summary
public ArArchiveEntry createArchiveEntry(final File inputFile, final String entryName) throws IOException

Implements abstract org.apache.commons.compress.archivers.ArchiveOutputStream.createArchiveEntry.

Doc from org.apache.commons.compress.archivers.ArchiveOutputStream.createArchiveEntry.

Creates an archive entry using the inputFile and entryName provided.

Parameters
inputFile:File

the file to create the entry from

entryName:String

name to use for the entry

Returns:ArArchiveEntry

the ArchiveEntry set up with details from the file

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
createArchiveEntryback to summary
public ArArchiveEntry createArchiveEntry(final Path inputPath, final String entryName, final LinkOption... options) throws IOException

Overrides org.apache.commons.compress.archivers.ArchiveOutputStream.createArchiveEntry.

Doc from org.apache.commons.compress.archivers.ArchiveOutputStream.createArchiveEntry.

Creates an archive entry using the inputPath and entryName provided.

The default implementation calls simply delegates as:

return createArchiveEntry(inputFile.toFile(), entryName);

Subclasses should override this method.

Parameters
inputPath:Path

the file to create the entry from

entryName:String

name to use for the entry

options:LinkOption[]

options indicating how symbolic links are handled.

Returns:ArArchiveEntry

the ArchiveEntry set up with details from the file

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
Since
1.21
fillback to summary
private long fill(final long pOffset, final long pNewOffset, final char pFill) throws IOException
finishback to summary
public void finish() throws IOException

Implements abstract org.apache.commons.compress.archivers.ArchiveOutputStream.finish.

Doc from org.apache.commons.compress.archivers.ArchiveOutputStream.finish.

Finishes the addition of entries to this stream, without closing it. Additional data can be written, if the format supports it.

Annotations
@Override
Exceptions
IOException:
if the user forgets to close the entry.
putArchiveEntryback to summary
public void putArchiveEntry(final ArArchiveEntry entry) throws IOException

Implements abstract org.apache.commons.compress.archivers.ArchiveOutputStream.putArchiveEntry.

Doc from org.apache.commons.compress.archivers.ArchiveOutputStream.putArchiveEntry.

Writes the headers for an archive entry to the output stream. The caller must then write the content to the stream and call closeArchiveEntry() to complete the process.

Parameters
entry:ArArchiveEntry

describes the entry

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
setLongFileModeback to summary
public void setLongFileMode(final int longFileMode)

Sets the long file mode. This can be LONGFILE_ERROR(0) or LONGFILE_BSD(1). This specifies the treatment of long file names (names >= 16). Default is LONGFILE_ERROR.

Parameters
longFileMode:int

the mode to use

Since
1.3
writeback to summary
public void write(final byte[] b, final int off, final int len) throws IOException

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation.

If b is null, a NullPointerException is thrown.

If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.

Parameters
b:byte[]

the data.

off:int

the start offset in the data.

len:int

the number of bytes to write.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs. In particular, an IOException is thrown if the output stream is closed.
writeback to summary
private long write(final String data) throws IOException
writeArchiveHeaderback to summary
private void writeArchiveHeader() throws IOException
writeEntryHeaderback to summary
private void writeEntryHeader(final ArArchiveEntry entry) throws IOException