The 7z file format is a flexible container that can contain many compression and encryption types, but at the moment only only Copy, LZMA, LZMA2, BZIP2, Deflate and AES-256 + SHA-256 are supported.
The format is very Windows/Intel specific, so it uses little-endian byte order, doesn't store user/group or permission bits, and represents times using NTFS timestamps (100 nanosecond units since 1 January 1601). Hence the official tools recommend against using it for backup purposes on *nix, and recommend .tar.7z or .tar.lzma or .tar.xz instead.
Both the header and file contents may be compressed and/or encrypted. With both encrypted, neither file names nor file contents can be read, but the use of encryption isn't plausibly deniable.
Multi volume archives can be read by concatenating the parts in correct order - either manually or by using {link org.apache.commons.compress.utils.MultiReadOnlySeekableByteChannel} for example.
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| public static class | SevenZFile.Builder
Builds new instances of |
| Modifier and Type | Field and Description |
|---|---|
| private final Archive | |
| private SeekableByteChannel | |
| private long | |
| private int | |
| private int | |
| private InputStream | |
| private static final String | |
| private final ArrayList | |
| private final String | |
| private final int | |
| private byte[] | |
| pack-priv static final byte[] | sevenZSignature
Shared with SevenZOutputFile and tests, neither mutates it. |
| pack-priv static final int | |
| private final boolean | |
| private long | |
| private final boolean |
| Access | Constructor and Description |
|---|---|
| public | SevenZFile(final File
the file to read. fileName)
Deprecated
Use
Reads a file as unencrypted 7z archive.
Builder#get().
|
| public | SevenZFile(final File
the file to read file, final byte[] optional password if the archive is encrypted - the byte array is supposed to be the UTF16-LE encoded representation of the password. password)
Deprecated
Use
Reads a file as 7z archive
Builder#get().
|
| public | SevenZFile(final File
the file to read file, final char[] optional password if the archive is encrypted password)
Deprecated
Use
Reads a file as 7z archive
Builder#get().
|
| public | SevenZFile(final File
the file to read file, final char[] optional password if the archive is encrypted password, final SevenZFileOptions the options to apply options)
Deprecated
Use
Reads a file as 7z archive with additional options.
Builder#get().
|
| public | SevenZFile(final File
the file to read file, final SevenZFileOptions the options to apply options)
Deprecated
Use
Reads a file as unencrypted 7z archive
Builder#get().
|
| public | SevenZFile(final SeekableByteChannel
the channel to read channel)
Deprecated
Use
Reads a SeekableByteChannel as 7z archive
Builder#get().
|
| public | SevenZFile(final SeekableByteChannel
the channel to read channel, final byte[] optional password if the archive is encrypted - the byte array is supposed to be the UTF16-LE encoded representation of the password. password)
Deprecated
Use
Reads a SeekableByteChannel as 7z archive
Builder#get().
|
| public | SevenZFile(final SeekableByteChannel
the channel to read channel, final char[] optional password if the archive is encrypted password)
Deprecated
Use
Reads a SeekableByteChannel as 7z archive
Builder#get().
|
| public | SevenZFile(final SeekableByteChannel
the channel to read channel, final char[] optional password if the archive is encrypted password, final SevenZFileOptions the options to apply options)
Deprecated
Use
Reads a SeekableByteChannel as 7z archive with additional options.
Builder#get().
|
| public | SevenZFile(final SeekableByteChannel
the channel to read channel, final SevenZFileOptions the options to apply options)
Deprecated
Use
Reads a SeekableByteChannel as 7z archive with additional options.
Builder#get().
|
| public | SevenZFile(final SeekableByteChannel
the channel to read channel, final String name of the archive - only used for error reporting fileName)
Deprecated
Use
Reads a SeekableByteChannel as 7z archive
Builder#get().
|
| public | SevenZFile(final SeekableByteChannel
the channel to read channel, final String name of the archive - only used for error reporting fileName, final byte[] optional password if the archive is encrypted - the byte array is supposed to be the UTF16-LE encoded representation of the password. password)
Deprecated
Use
Reads a SeekableByteChannel as 7z archive
Builder#get().
|
| private | SevenZFile(final SeekableByteChannel channel, final String fileName, final byte[] password, final boolean closeOnError, final int maxMemoryLimitKb, final boolean useDefaultNameForUnnamedEntries, final boolean tryToRecoverBrokenArchives)
|
| private | SevenZFile(final SeekableByteChannel
the channel to read. channel, final String name of the archive - only used for error reporting. fileName, final byte[] optional password if the archive is encrypted. password, final boolean closes the channel on error. closeOnError, final SevenZFileOptions options. options)
Deprecated
Use
Constructs a new instance.
Builder#get().
|
| public | SevenZFile(final SeekableByteChannel
the channel to read channel, final String name of the archive - only used for error reporting fileName, final char[] optional password if the archive is encrypted password)
Deprecated
Use
Reads a SeekableByteChannel as 7z archive
Builder#get().
|
| public | SevenZFile(final SeekableByteChannel
the channel to read channel, final String name of the archive - only used for error reporting fileName, final char[] optional password if the archive is encrypted password, final SevenZFileOptions the options to apply options)
Deprecated
Use
Reads a SeekableByteChannel as 7z archive with additional options.
Builder#get().
|
| public | SevenZFile(final SeekableByteChannel
the channel to read channel, final String name of the archive - only used for error reporting fileName, final SevenZFileOptions the options to apply options)
Deprecated
Use
Reads a SeekableByteChannel as 7z archive with additional options.
Builder#get().
|
| Modifier and Type | Method and Description |
|---|---|
| private static int | |
| private InputStream | buildDecoderStack(final Folder folder, final long folderOffset, final int firstPackStreamIndex, final SevenZArchiveEntry entry)
|
| private void | buildDecodingStream(final int
the index of the entry to be read entryIndex, final boolean is this called in a random access isRandomAccess)Builds the decoding stream for the entry to be read. |
| public static SevenZFile. | |
| private void | |
| private static ByteBuffer | |
| private void | |
| public void | |
| private static void | |
| private static char | |
| private InputStream | |
| public String | Returns: null if the name of the archive is unknown. Otherwise, if the name of the archive has got any extension, it is stripped and the remainder returned. Finally, if the name of the archive hasn't got any extension, then a~ character is appended to the archive name.Gets a default file name from the archive name - if known. |
| public Iterable | Returns: a copy of meta-data of all archive entries.Gets a copy of meta-data of all archive entries. |
| public InputStream | Returns: a stream to read the entry from.the entry to get the stream for. entry)Gets an InputStream for reading the contents of the given entry. |
| private static int | |
| private static long | |
| public SevenZArchiveEntry | Returns: the next entry, ornull if there are no more entriesGets the next Archive Entry in this archive. |
| public InputStreamStatistics | Returns: statistics for bytes read from the current entryGets statistics for bytes read from the current entry. |
| private static int | |
| private boolean | Returns: true if any data of current entry has been readTests if any data of current entry has been read or not. |
| private Archive | |
| public static boolean | Returns: true, if this is the signature of a 7z archive.the bytes to check signature, final int the number of bytes to check length)Checks if the signature matches what is expected for a 7z file. |
| private static SeekableByteChannel | |
| public int | |
| public int | Returns: the number of bytes read, or -1 if end of input is reachedthe array to write data to b)Reads data into an array of bytes. |
| public int | Returns: the number of bytes read, or -1 if end of input is reachedthe array to write data to b, final int offset into the buffer to start filling at off, final int of bytes to read len)Reads data into an array of bytes. |
| private BitSet | |
| private void | |
| private BitSet | |
| private ByteBuffer | |
| private void | |
| private Folder | |
| private void | |
| private void | |
| private Archive | |
| private void | |
| private StartHeader | |
| private void | |
| private void | |
| private static long | |
| private void | |
| private void | reopenFolderInputStream(final int
the index of the folder to reopen folderIndex, final SevenZArchiveEntry the 7z entry to read file)Discard any queued streams/ folder stream, and reopen the current folder input stream. |
| private SevenZFile. | |
| private void | |
| private void | |
| private int | |
| private void | |
| private void | |
| private void | |
| private void | |
| private static long | |
| private boolean | Returns: true if there are entries actually skippedthe entry to be read entryIndex, final boolean are the entry to be read and the current entry in the same folder isInSameFolder, final int the index of the folder which contains the entry folderIndex)Skips all the entries if needed. |
| public String | |
| private Archive |