Class ArArchiveOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.apache.commons.compress.archivers.ArchiveOutputStream<ArArchiveEntry>
org.apache.commons.compress.archivers.ar.ArArchiveOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
Implements the "ar" archive format as an output stream.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprivate intstatic final intBSD ar extensions are used to store long file names in the archive.static final intFail if a long file name is required in the archive.private intprivate static final charprivate ArArchiveEntryprivate booleanprivate static final charFields inherited from class java.io.FilterOutputStream
out -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate StringcheckLength(String value, int max, String name) voidclose()Calls finish if necessary, and then closes the OutputStreamvoidCloses the archive entry, writing any trailer information that may be required.createArchiveEntry(File inputFile, String entryName) Creates an archive entry using the inputFile and entryName provided.createArchiveEntry(Path inputPath, String entryName, LinkOption... options) Creates an archive entry using the inputPath and entryName provided.voidfinish()Finishes the addition of entries to this stream, without closing it.private intpad(int offset, int newOffset, char fill) voidputArchiveEntry(ArArchiveEntry entry) Writes the headers for an archive entry to the output stream.voidsetLongFileMode(int longFileMode) Sets the long file mode.voidwrite(byte[] b, int off, int len) private intprivate voidprivate intwriteEntryHeader(ArArchiveEntry entry) Methods inherited from class org.apache.commons.compress.archivers.ArchiveOutputStream
canWriteEntryData, checkFinished, checkOpen, count, count, getBytesWritten, getCount, isClosed, isFinished, writeMethods inherited from class java.io.FilterOutputStream
flush, write
-
Field Details
-
PAD
private static final char PAD- See Also:
-
SPACE
private static final char SPACE- See Also:
-
LONGFILE_ERROR
public static final int LONGFILE_ERRORFail if a long file name is required in the archive.- See Also:
-
LONGFILE_BSD
public static final int LONGFILE_BSDBSD ar extensions are used to store long file names in the archive.- See Also:
-
entryOffset
private long entryOffset -
headerPlus
private int headerPlus -
prevEntry
-
prevEntryOpen
private boolean prevEntryOpen -
longFileMode
private int longFileMode
-
-
Constructor Details
-
ArArchiveOutputStream
-
-
Method Details
-
checkLength
- Throws:
IOException
-
close
Calls finish if necessary, and then closes the OutputStream- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classArchiveOutputStream<ArArchiveEntry>- Throws:
IOException
-
closeArchiveEntry
Description copied from class:ArchiveOutputStreamCloses the archive entry, writing any trailer information that may be required.- Specified by:
closeArchiveEntryin classArchiveOutputStream<ArArchiveEntry>- Throws:
IOException- if an I/O error occurs
-
createArchiveEntry
Description copied from class:ArchiveOutputStreamCreates an archive entry using the inputFile and entryName provided.- Specified by:
createArchiveEntryin classArchiveOutputStream<ArArchiveEntry>- Parameters:
inputFile- the file to create the entry fromentryName- name to use for the entry- Returns:
- the ArchiveEntry set up with details from the file
- Throws:
IOException- if an I/O error occurs
-
createArchiveEntry
public ArArchiveEntry createArchiveEntry(Path inputPath, String entryName, LinkOption... options) throws IOException 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.
- Overrides:
createArchiveEntryin classArchiveOutputStream<ArArchiveEntry>- Parameters:
inputPath- the file to create the entry fromentryName- name to use for the entryoptions- options indicating how symbolic links are handled.- Returns:
- the ArchiveEntry set up with details from the file
- Throws:
IOException- if an I/O error occurs- Since:
- 1.21
-
finish
Description copied from class:ArchiveOutputStreamFinishes the addition of entries to this stream, without closing it. Additional data can be written, if the format supports it.- Overrides:
finishin classArchiveOutputStream<ArArchiveEntry>- Throws:
IOException- Maybe thrown by subclasses if the user forgets to close the entry.
-
pad
- Throws:
IOException
-
putArchiveEntry
Description copied from class:ArchiveOutputStreamWrites the headers for an archive entry to the output stream. The caller must then write the content to the stream and callArchiveOutputStream.closeArchiveEntry()to complete the process.- Specified by:
putArchiveEntryin classArchiveOutputStream<ArArchiveEntry>- Parameters:
entry- describes the entry- Throws:
IOException- if an I/O error occurs
-
setLongFileMode
public void setLongFileMode(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- the mode to use- Since:
- 1.3
-
write
- Overrides:
writein classFilterOutputStream- Throws:
IOException
-
write
- Throws:
IOException
-
writeArchiveHeader
- Throws:
IOException
-
writeEntryHeader
- Throws:
IOException
-