Class TarFile
java.lang.Object
org.apache.commons.compress.archivers.tar.TarFile
- All Implemented Interfaces:
Closeable
,AutoCloseable
Provides random access to UNIX archives.
- Since:
- 1.21
-
Constructor Summary
ConstructorDescriptionTarFile
(byte[] content) Constructor for TarFile.TarFile
(byte[] content, boolean lenient) Constructor for TarFile.Constructor for TarFile.Constructor for TarFile.Constructor for TarFile.Constructor for TarFile.TarFile
(SeekableByteChannel content) Constructor for TarFile.TarFile
(SeekableByteChannel archive, int blockSize, int recordSize, String encoding, boolean lenient) Constructor for TarFile.Constructor for TarFile.Constructor for TarFile.Constructor for TarFile. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Gets all TAR Archive Entries from the TarFilegetInputStream
(TarArchiveEntry entry) Gets the input stream for the provided Tar Archive Entry.protected final boolean
isAtEOF()
protected final void
setAtEOF
(boolean b)
-
Constructor Details
-
TarFile
Constructor for TarFile.- Parameters:
content
- the content to use- Throws:
IOException
- when reading the tar archive fails
-
TarFile
Constructor for TarFile.- Parameters:
content
- the content to uselenient
- when set to true illegal values for group/userid, mode, device numbers and timestamp will be ignored and the fields set toTarArchiveEntry.UNKNOWN
. When set to false such illegal fields cause an exception instead.- Throws:
IOException
- when reading the tar archive fails
-
TarFile
Constructor for TarFile.- Parameters:
content
- the content to useencoding
- the encoding to use- Throws:
IOException
- when reading the tar archive fails
-
TarFile
Constructor for TarFile.- Parameters:
archive
- the file of the archive to use- Throws:
IOException
- when reading the tar archive fails
-
TarFile
Constructor for TarFile.- Parameters:
archive
- the file of the archive to uselenient
- when set to true illegal values for group/userid, mode, device numbers and timestamp will be ignored and the fields set toTarArchiveEntry.UNKNOWN
. When set to false such illegal fields cause an exception instead.- Throws:
IOException
- when reading the tar archive fails
-
TarFile
Constructor for TarFile.- Parameters:
archive
- the file of the archive to useencoding
- the encoding to use- Throws:
IOException
- when reading the tar archive fails
-
TarFile
Constructor for TarFile.- Parameters:
archivePath
- the path of the archive to use- Throws:
IOException
- when reading the tar archive fails
-
TarFile
Constructor for TarFile.- Parameters:
archivePath
- the path of the archive to uselenient
- when set to true illegal values for group/userid, mode, device numbers and timestamp will be ignored and the fields set toTarArchiveEntry.UNKNOWN
. When set to false such illegal fields cause an exception instead.- Throws:
IOException
- when reading the tar archive fails
-
TarFile
Constructor for TarFile.- Parameters:
archivePath
- the path of the archive to useencoding
- the encoding to use- Throws:
IOException
- when reading the tar archive fails
-
TarFile
Constructor for TarFile.- Parameters:
content
- the content to use- Throws:
IOException
- when reading the tar archive fails
-
TarFile
public TarFile(SeekableByteChannel archive, int blockSize, int recordSize, String encoding, boolean lenient) throws IOException Constructor for TarFile.- Parameters:
archive
- the seekable byte channel to useblockSize
- the blocks size to userecordSize
- the record size to useencoding
- the encoding to uselenient
- when set to true illegal values for group/userid, mode, device numbers and timestamp will be ignored and the fields set toTarArchiveEntry.UNKNOWN
. When set to false such illegal fields cause an exception instead.- Throws:
IOException
- when reading the tar archive fails
-
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
getEntries
Gets all TAR Archive Entries from the TarFile- Returns:
- All entries from the tar file
-
getInputStream
Gets the input stream for the provided Tar Archive Entry.- Parameters:
entry
- Entry to get the input stream from- Returns:
- Input stream of the provided entry
- Throws:
IOException
- Corrupted TAR archive. Can't read entry.
-
isAtEOF
-
setAtEOF
-