Class SevenZOutputFile
java.lang.Object
org.apache.commons.compress.archivers.sevenz.SevenZOutputFile
- All Implemented Interfaces:
- Closeable,- AutoCloseable
Writes a 7z file.
- Since:
- 1.6
- 
Constructor SummaryConstructorsConstructorDescriptionSevenZOutputFile(File fileName) Opens file to write a 7z archive to.SevenZOutputFile(File fileName, char[] password) Opens file to write a 7z archive to.SevenZOutputFile(SeekableByteChannel channel) Prepares channel to write a 7z archive to.SevenZOutputFile(SeekableByteChannel channel, char[] password) Prepares channel to write a 7z archive to.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Closes the archive, callingfinish()if necessary.voidCloses the archive entry.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 archive, without closing it.voidputArchiveEntry(ArchiveEntry archiveEntry) Deprecated.voidputArchiveEntry(SevenZArchiveEntry archiveEntry) Records an archive entry to add.voidsetContentCompression(SevenZMethod method) Sets the default compression method to use for entry contents - the default is LZMA2.voidsetContentMethods(Iterable<? extends SevenZMethodConfiguration> methods) Sets the default (compression) methods to use for entry contents - the default is LZMA2.voidwrite(byte[] b) Writes a byte array to the current archive entry.voidwrite(byte[] b, int off, int len) Writes part of a byte array to the current archive entry.voidwrite(int b) Writes a byte to the current archive entry.voidwrite(InputStream inputStream) Writes all of the given input stream to the current archive entry.voidwrite(Path path, OpenOption... options) Writes all of the given input stream to the current archive entry.
- 
Constructor Details- 
SevenZOutputFileOpens file to write a 7z archive to.- Parameters:
- fileName- the file to write to
- Throws:
- IOException- if opening the file fails
 
- 
SevenZOutputFileOpens file to write a 7z archive to.- Parameters:
- fileName- the file to write to
- password- optional password if the archive has to be encrypted
- Throws:
- IOException- if opening the file fails
- Since:
- 1.23
 
- 
SevenZOutputFilePrepares channel to write a 7z archive to.SeekableInMemoryByteChannelallows you to write to an in-memory archive.- Parameters:
- channel- the channel to write to
- Throws:
- IOException- if the channel cannot be positioned properly
- Since:
- 1.13
 
- 
SevenZOutputFilePrepares channel to write a 7z archive to.SeekableInMemoryByteChannelallows you to write to an in-memory archive.- Parameters:
- channel- the channel to write to
- password- optional password if the archive has to be encrypted
- Throws:
- IOException- if the channel cannot be positioned properly
- Since:
- 1.23
 
 
- 
- 
Method Details- 
closeCloses the archive, callingfinish()if necessary.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Throws:
- IOException- on error
 
- 
closeArchiveEntryCloses the archive entry.- Throws:
- IOException- on error
 
- 
createArchiveEntryCreates an archive entry using the inputFile and entryName provided.- Parameters:
- inputFile- file to create an entry from
- entryName- the name to use
- Returns:
- the ArchiveEntry set up with details from the file
 
- 
createArchiveEntrypublic SevenZArchiveEntry createArchiveEntry(Path inputPath, String entryName, LinkOption... options) throws IOException Creates an archive entry using the inputPath and entryName provided.- Parameters:
- inputPath- path to create an entry from
- entryName- the name to use
- options- options indicating how symbolic links are handled.
- Returns:
- the ArchiveEntry set up with details from the file
- Throws:
- IOException- on error
- Since:
- 1.21
 
- 
finishFinishes the addition of entries to this archive, without closing it.- Throws:
- IOException- if archive is already closed.
 
- 
putArchiveEntryDeprecated.Records an archive entry to add. The caller must then write the content to the archive and callcloseArchiveEntry()to complete the process.- Parameters:
- archiveEntry- describes the entry
 
- 
putArchiveEntryRecords an archive entry to add. The caller must then write the content to the archive and callcloseArchiveEntry()to complete the process.- Parameters:
- archiveEntry- describes the entry
- Since:
- 1.25.0
 
- 
setContentCompressionSets the default compression method to use for entry contents - the default is LZMA2.Currently only SevenZMethod.COPY,SevenZMethod.LZMA2,SevenZMethod.BZIP2andSevenZMethod.DEFLATEare supported.This is a short form for passing a single-element iterable to setContentMethods(java.lang.Iterable<? extends org.apache.commons.compress.archivers.sevenz.SevenZMethodConfiguration>).- Parameters:
- method- the default compression method
 
- 
setContentMethodsSets the default (compression) methods to use for entry contents - the default is LZMA2.Currently only SevenZMethod.COPY,SevenZMethod.LZMA2,SevenZMethod.BZIP2andSevenZMethod.DEFLATEare supported.The methods will be consulted in iteration order to create the final output. - Parameters:
- methods- the default (compression) methods
- Since:
- 1.8
 
- 
writeWrites a byte array to the current archive entry.- Parameters:
- b- The byte array to be written.
- Throws:
- IOException- on error
 
- 
writeWrites part of a byte array to the current archive entry.- Parameters:
- b- The byte array to be written.
- off- offset into the array to start writing from
- len- number of bytes to write
- Throws:
- IOException- on error
 
- 
writeWrites all of the given input stream to the current archive entry.- Parameters:
- inputStream- the data source.
- Throws:
- IOException- if an I/O error occurs.
- Since:
- 1.21
 
- 
writeWrites a byte to the current archive entry.- Parameters:
- b- The byte to be written.
- Throws:
- IOException- on error
 
- 
writeWrites all of the given input stream to the current archive entry.- Parameters:
- path- the data source.
- options- options specifying how the file is opened.
- Throws:
- IOException- if an I/O error occurs.
- Since:
- 1.21
 
 
- 
putArchiveEntry(SevenZArchiveEntry).