TarArchive
Inheritance: java.lang.Object
All Implemented Interfaces: com.aspose.zip.IArchive, java.lang.AutoCloseable
public class TarArchive implements IArchive, AutoCloseable
This class represents tar archive file. Use it to compose, extract, or update tar archives.
Constructors
Constructor | Description |
---|---|
TarArchive() | Initializes a new instance of the TarArchive class. |
TarArchive(InputStream sourceStream) | Initializes a new instance of the Archive class and composes entries list can be extracted from the archive. |
TarArchive(String path) | Initializes a new instance of the TarArchive class and composes entries list can be extracted from the archive. |
Methods
Method | Description |
---|---|
close() | {@inheritDoc} |
createEntries(File directory) | Adds to the archive all the files and directories recursively in the directory given. |
createEntries(File directory, boolean includeRootDirectory) | Adds to the archive all the files and directories recursively in the directory given. |
createEntries(String sourceDirectory) | Adds to the archive all the files and directories recursively in the directory given. |
createEntries(String sourceDirectory, boolean includeRootDirectory) | Adds to the archive all the files and directories recursively in the directory given. |
createEntry(String name, File file) | Create single entry within the archive. |
createEntry(String name, File file, boolean openImmediately) | Create single entry within the archive. |
createEntry(String name, InputStream source) | Create single entry within the archive. |
createEntry(String name, InputStream source, File file) | Create single entry within the archive. |
createEntry(String name, String path) | Create single entry within the archive. |
createEntry(String name, String path, boolean openImmediately) | Create single entry within the archive. |
deleteEntry(TarEntry entry) | Removes the first occurrence of a specific entry from the entries list. |
deleteEntry(int entryIndex) | Removes the entry from the entries list by index. |
extractToDirectory(String destinationDirectory) | Extracts all the files in the archive to the directory provided. |
fromGZip(InputStream source) | Extracts supplied gzip archive and composes TarArchive from extracted data. |
fromGZip(String path) | Extracts supplied gzip archive and composes TarArchive from extracted data. |
fromLZMA(InputStream source) | Extracts supplied LZMA archive and composes TarArchive from extracted data. |
fromLZMA(String path) | Extracts supplied LZMA archive and composes TarArchive from extracted data. |
fromLZip(InputStream source) | Extracts supplied lzip archive and composes TarArchive from extracted data. |
fromLZip(String path) | Extracts supplied lzip archive and composes TarArchive from extracted data. |
fromXz(InputStream source) | Extracts supplied xz format archive and composes TarArchive from extracted data. |
fromXz(String path) | Extracts supplied xz format archive and composes TarArchive from extracted data. |
fromZ(InputStream source) | Extracts supplied Z format archive and composes TarArchive from extracted data. |
fromZ(String path) | Extracts supplied Z format archive and composes TarArchive from extracted data. |
fromZstandard(InputStream source) | Extracts supplied Zstandard archive and composes TarArchive from extracted data. |
fromZstandard(String path) | Extracts supplied Zstandard archive and composes TarArchive from extracted data. |
getEntries() | Gets entries of TarEntry type constituting the archive. |
getFileEntries() | Gets entries of IArchiveFileEntry type constituting the tar archive. |
save(OutputStream output) | Saves archive to the stream provided. |
save(OutputStream output, TarFormat format) | Saves archive to the stream provided. |
save(String destinationFileName) | Saves archive to destination file provided. |
save(String destinationFileName, TarFormat format) | Saves archive to destination file provided. |
saveGzipped(OutputStream output) | Saves archive to the stream with gzip compression. |
saveGzipped(OutputStream output, TarFormat format) | Saves archive to the stream with gzip compression. |
saveGzipped(String path) | Saves archive to the file by path with gzip compression. |
saveGzipped(String path, TarFormat format) | Saves archive to the file by path with gzip compression. |
saveLZMACompressed(OutputStream output) | Saves archive to the stream with LZMA compression. |
saveLZMACompressed(OutputStream output, TarFormat format) | Saves archive to the stream with LZMA compression. |
saveLZMACompressed(String path) | Saves archive to the file by path with lzma compression. |
saveLZMACompressed(String path, TarFormat format) | Saves archive to the file by path with lzma compression. |
saveLzipped(OutputStream output) | Saves archive to the stream with lzip compression. |
saveLzipped(OutputStream output, TarFormat format) | Saves archive to the stream with lzip compression. |
saveLzipped(String path) | Saves archive to the file by path with lzip compression. |
saveLzipped(String path, TarFormat format) | Saves archive to the file by path with lzip compression. |
saveXzCompressed(OutputStream output) | Saves archive to the stream with xz compression. |
saveXzCompressed(OutputStream output, TarFormat format) | Saves archive to the stream with xz compression. |
saveXzCompressed(OutputStream output, TarFormat format, XzArchiveSettings settings) | Saves archive to the stream with xz compression. |
saveXzCompressed(String path) | Saves archive to the file by path with xz compression. |
saveXzCompressed(String path, TarFormat format) | Saves archive to the file by path with xz compression. |
saveXzCompressed(String path, TarFormat format, XzArchiveSettings settings) | Saves archive to the file by path with xz compression. |
saveZCompressed(OutputStream output) | Saves archive to the stream with Z compression. |
saveZCompressed(OutputStream output, TarFormat format) | Saves archive to the stream with Z compression. |
saveZCompressed(String path) | Saves archive to the file by path with Z compression. |
saveZCompressed(String path, TarFormat format) | Saves archive to the file by path with Z compression. |
saveZstandard(OutputStream output) | Saves archive to the stream with Zstandard compression. |
saveZstandard(OutputStream output, TarFormat format) | Saves archive to the stream with Zstandard compression. |
saveZstandard(String path) | Saves archive to the file by path with Zstandard compression. |
saveZstandard(String path, TarFormat format) | Saves archive to the file by path with Zstandard compression. |
TarArchive()
public TarArchive()
Initializes a new instance of the TarArchive class.
The following example shows how to compress a file.
try (TarArchive archive = new TarArchive()) {
archive.createEntry(first.bin, "data.bin");
archive.save("archive.tar");
}
TarArchive(InputStream sourceStream)
public TarArchive(InputStream sourceStream)
Initializes a new instance of the Archive class and composes entries list can be extracted from the archive.
The following example shows how to extract all of the entries to a directory.
try (TarArchive archive = new TarArchive(new FileInputStream("archive.tar"))) {
archive.extractToDirectory("C:\\extracted");
} catch (IOException ex) {
System.out.println(ex);
}
This constructor does not unpack any entry. See TarEntry.open() method for unpacking.
Parameters:
Parameter | Type | Description |
---|---|---|
sourceStream | java.io.InputStream | the source of the archive |
TarArchive(String path)
public TarArchive(String path)
Initializes a new instance of the TarArchive class and composes entries list can be extracted from the archive.
The following example shows how to extract all of the entries to a directory.
try (TarArchive archive = new TarArchive("archive.tar")) {
archive.extractToDirectory("C:\\extracted");
}
This constructor does not unpack any entry. See TarEntry.open() method for unpacking.
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path to the archive file |
close()
public void close()
createEntries(File directory)
public final TarArchive createEntries(File directory)
Adds to the archive all the files and directories recursively in the directory given.
try (FileOutputStream tarFile = new FileOutputStream("archive.tar")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntries(new java.io.File("C:\\folder"), false);
archive.save(tarFile);
}
} catch (IOException ex) {
System.out.println(ex);
}
Parameters:
Parameter | Type | Description |
---|---|---|
directory | java.io.File | directory to compress |
Returns: TarArchive - the archive with entries composed
createEntries(File directory, boolean includeRootDirectory)
public final TarArchive createEntries(File directory, boolean includeRootDirectory)
Adds to the archive all the files and directories recursively in the directory given.
try (FileOutputStream tarFile = new FileOutputStream("archive.tar")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntries(new java.io.File("C:\\folder"), false);
archive.save(tarFile);
}
} catch (IOException ex) {
System.out.println(ex);
}
Parameters:
Parameter | Type | Description |
---|---|---|
directory | java.io.File | directory to compress |
includeRootDirectory | boolean | indicates whether to include the root directory itself or not |
Returns: TarArchive - the archive with entries composed
createEntries(String sourceDirectory)
public final TarArchive createEntries(String sourceDirectory)
Adds to the archive all the files and directories recursively in the directory given.
try (FileOutputStream tarFile = new FileOutputStream("archive.tar")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntries("C:\\folder", false);
archive.save(tarFile);
}
} catch (IOException ex) {
System.out.println(ex);
}
Parameters:
Parameter | Type | Description |
---|---|---|
sourceDirectory | java.lang.String | directory to compress |
Returns: TarArchive - the archive with entries composed
createEntries(String sourceDirectory, boolean includeRootDirectory)
public final TarArchive createEntries(String sourceDirectory, boolean includeRootDirectory)
Adds to the archive all the files and directories recursively in the directory given.
try (FileOutputStream tarFile = new FileOutputStream("archive.tar")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntries("C:\\folder", false);
archive.save(tarFile);
}
} catch (IOException ex) {
System.out.println(ex);
}
Parameters:
Parameter | Type | Description |
---|---|---|
sourceDirectory | java.lang.String | directory to compress |
includeRootDirectory | boolean | indicates whether to include the root directory itself or not |
Returns: TarArchive - the archive with entries composed
createEntry(String name, File file)
public final TarEntry createEntry(String name, File file)
Create single entry within the archive.
File fi = new File("data.bin");
try (TarArchive archive = new TarArchive()) {
archive.createEntry("data.bin", fi);
archive.save(tarFile);
}
The entry name is solely set within name
parameter. The file name provided in file
parameter does not affect the entry name.
Parameters:
Parameter | Type | Description |
---|---|---|
name | java.lang.String | the name of the entry |
file | java.io.File | the metadata of file or folder to be compressed |
Returns: TarEntry - Tar entry instance
createEntry(String name, File file, boolean openImmediately)
public final TarEntry createEntry(String name, File file, boolean openImmediately)
Create single entry within the archive.
File fi = new File("data.bin");
try (TarArchive archive = new TarArchive()) {
archive.createEntry("data.bin", fi);
archive.save(tarFile);
}
The entry name is solely set within name
parameter. The file name provided in file
parameter does not affect the entry name.
If the file is opened immediately with openImmediately
parameter it becomes blocked until archive is disposed.
Parameters:
Parameter | Type | Description |
---|---|---|
name | java.lang.String | the name of the entry |
file | java.io.File | the metadata of file or folder to be compressed |
openImmediately | boolean | true if open the file immediately, otherwise open the file on archive saving |
Returns: TarEntry - Tar entry instance
createEntry(String name, InputStream source)
public final TarEntry createEntry(String name, InputStream source)
Create single entry within the archive.
try (TarArchive archive = new TarArchive()) {
archive.createEntry("bytes", new ByteArrayInputStream(new byte[] {0x00, (byte) 0xFF}));
archive.save(tarFile);
}
The entry name is solely set within name
parameter.
Parameters:
Parameter | Type | Description |
---|---|---|
name | java.lang.String | the name of the entry |
source | java.io.InputStream | the input stream for the entry |
Returns: TarEntry - Tar entry instance
createEntry(String name, InputStream source, File file)
public final TarEntry createEntry(String name, InputStream source, File file)
Create single entry within the archive.
try (TarArchive archive = new TarArchive()) {
archive.createEntry("bytes", new ByteArrayInputStream(new byte[] {0x00, (byte) 0xFF}));
archive.save(tarFile);
}
The entry name is solely set within name
parameter. The file name provided in file
parameter does not affect the entry name.
Parameters:
Parameter | Type | Description |
---|---|---|
name | java.lang.String | the name of the entry |
source | java.io.InputStream | the input stream for the entry |
file | java.io.File | the metadata of file or folder to be compressed |
Returns: TarEntry - Tar entry instance
createEntry(String name, String path)
public final TarEntry createEntry(String name, String path)
Create single entry within the archive.
try (TarArchive archive = new TarArchive()) {
archive.createEntry(first.bin, "data.bin");
archive.save(outputTarFile);
}
The entry name is solely set within name
parameter. The file name provided in path
parameter does not affect the entry name.
Parameters:
Parameter | Type | Description |
---|---|---|
name | java.lang.String | the name of the entry |
path | java.lang.String | path to file to be compressed |
Returns: TarEntry - Tar entry instance
createEntry(String name, String path, boolean openImmediately)
public final TarEntry createEntry(String name, String path, boolean openImmediately)
Create single entry within the archive.
try (TarArchive archive = new TarArchive()) {
archive.createEntry(first.bin, "data.bin");
archive.save(outputTarFile);
}
The entry name is solely set within name
parameter. The file name provided in path
parameter does not affect the entry name.
If the file is opened immediately with openImmediately
parameter it becomes blocked until archive is disposed.
Parameters:
Parameter | Type | Description |
---|---|---|
name | java.lang.String | the name of the entry |
path | java.lang.String | path to file to be compressed |
openImmediately | boolean | true if open the file immediately, otherwise open the file on archive saving |
Returns: TarEntry - Tar entry instance
deleteEntry(TarEntry entry)
public final TarArchive deleteEntry(TarEntry entry)
Removes the first occurrence of a specific entry from the entries list.
Here is how you can remove all entries except the last one:
try (TarArchive archive = new TarArchive("archive.tar")) {
while (archive.getEntries().size() > 1)
archive.deleteEntry(archive.getEntries().get_Item(0));
archive.save(outputTarFile);
}
Parameters:
Parameter | Type | Description |
---|---|---|
entry | TarEntry | the entry to remove from the entries list |
Returns: TarArchive - the archive with the entry deleted
deleteEntry(int entryIndex)
public final TarArchive deleteEntry(int entryIndex)
Removes the entry from the entries list by index.
try (TarArchive archive = new TarArchive("two_files.tar")) {
archive.deleteEntry(0);
archive.save("single_file.tar");
}
Parameters:
Parameter | Type | Description |
---|---|---|
entryIndex | int | the zero-based index of the entry to remove |
Returns: TarArchive - the archive with the entry deleted
extractToDirectory(String destinationDirectory)
public final void extractToDirectory(String destinationDirectory)
Extracts all the files in the archive to the directory provided.
try (TarArchive archive = new TarArchive("archive.tar")) {
archive.extractToDirectory("C:\\extracted");
}
If the directory does not exist, it will be created.
Parameters:
Parameter | Type | Description |
---|---|---|
destinationDirectory | java.lang.String | the path to the directory to place the extracted files in |
fromGZip(InputStream source)
public static TarArchive fromGZip(InputStream source)
Extracts supplied gzip archive and composes TarArchive from extracted data.
Important: gzip archive is fully extracted within this method, its content is kept internally. Beware of memory consumption.
GZip extraction stream is not seekable by the nature of compression algorithm. Tar archive provides facility to extract arbitrary record, so it has to operate seekable stream under the hood
Parameters:
Parameter | Type | Description |
---|---|---|
source | java.io.InputStream | the source of the archive. |
Returns: TarArchive - an instance of TarArchive
fromGZip(String path)
public static TarArchive fromGZip(String path)
Extracts supplied gzip archive and composes TarArchive from extracted data.
Important: gzip archive is fully extracted within this method, its content is kept internally. Beware of memory consumption.
GZip extraction stream is not seekable by the nature of compression algorithm. Tar archive provides facility to extract arbitrary record, so it has to operate seekable stream under the hood
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path to the archive file. |
Returns: TarArchive - an instance of TarArchive
fromLZMA(InputStream source)
public static TarArchive fromLZMA(InputStream source)
Extracts supplied LZMA archive and composes TarArchive from extracted data.
Important: LZMA archive is fully extracted within this method, its content is kept internally. Beware of memory consumption.
LZMA extraction stream is not seekable by the nature of compression algorithm. Tar archive provides facility to extract arbitrary record, so it has to operate seekable stream under the hood.
Parameters:
Parameter | Type | Description |
---|---|---|
source | java.io.InputStream | the source of the archive |
Returns: TarArchive - an instance of TarArchive
fromLZMA(String path)
public static TarArchive fromLZMA(String path)
Extracts supplied LZMA archive and composes TarArchive from extracted data.
Important: LZMA archive is fully extracted within this method, its content is kept internally. Beware of memory consumption.
LZMA extraction stream is not seekable by the nature of compression algorithm. Tar archive provides facility to extract arbitrary record, so it has to operate seekable stream under the hood.
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path to the archive file |
Returns: TarArchive - an instance of TarArchive
fromLZip(InputStream source)
public static TarArchive fromLZip(InputStream source)
Extracts supplied lzip archive and composes TarArchive from extracted data.
Important: lzip archive is fully extracted within this method, its content is kept internally. Beware of memory consumption.
Lzip extraction stream is not seekable by the nature of compression algorithm. Tar archive provides facility to extract arbitrary record, so it has to operate seekable stream under the hood
Parameters:
Parameter | Type | Description |
---|---|---|
source | java.io.InputStream | the source of the archive. |
Returns: TarArchive - an instance of TarArchive
fromLZip(String path)
public static TarArchive fromLZip(String path)
Extracts supplied lzip archive and composes TarArchive from extracted data.
Important: lzip archive is fully extracted within this method, its content is kept internally. Beware of memory consumption.
Lzip extraction stream is not seekable by the nature of compression algorithm. Tar archive provides facility to extract arbitrary record, so it has to operate seekable stream under the hood
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path to the archive file. |
Returns: TarArchive - an instance of TarArchive
fromXz(InputStream source)
public static TarArchive fromXz(InputStream source)
Extracts supplied xz format archive and composes TarArchive from extracted data.
Important: xz archive is fully extracted within this method, its content is kept internally. Beware of memory consumption.
Tar archive provides facility to extract arbitrary record, so it has to operate seekable stream under the hood.
Parameters:
Parameter | Type | Description |
---|---|---|
source | java.io.InputStream | the source of the archive |
Returns: TarArchive - an instance of TarArchive
fromXz(String path)
public static TarArchive fromXz(String path)
Extracts supplied xz format archive and composes TarArchive from extracted data.
Important: xz archive is fully extracted within this method, its content is kept internally. Beware of memory consumption.
Tar archive provides facility to extract arbitrary record, so it has to operate seekable stream under the hood.
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path to the archive file |
Returns: TarArchive - an instance of TarArchive
fromZ(InputStream source)
public static TarArchive fromZ(InputStream source)
Extracts supplied Z format archive and composes TarArchive from extracted data.
Important: Z archive is fully extracted within this method, its content is kept internally. Beware of memory consumption.
Parameters:
Parameter | Type | Description |
---|---|---|
source | java.io.InputStream | the source of the archive |
Returns: TarArchive - an instance of TarArchive
fromZ(String path)
public static TarArchive fromZ(String path)
Extracts supplied Z format archive and composes TarArchive from extracted data.
Important: Z archive is fully extracted within this method, its content is kept internally. Beware of memory consumption.
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path to the archive file |
Returns: TarArchive - an instance of TarArchive
fromZstandard(InputStream source)
public static TarArchive fromZstandard(InputStream source)
Extracts supplied Zstandard archive and composes TarArchive from extracted data.
Important: Zstandard archive is fully extracted within this method, its content is kept internally. Beware of memory consumption.
Parameters:
Parameter | Type | Description |
---|---|---|
source | java.io.InputStream | the source of the archive |
Returns: TarArchive - an instance of TarArchive
fromZstandard(String path)
public static TarArchive fromZstandard(String path)
Extracts supplied Zstandard archive and composes TarArchive from extracted data.
Important: Zstandard archive is fully extracted within this method, its content is kept internally. Beware of memory consumption.
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path to the archive file |
Returns: TarArchive - an instance of TarArchive
getEntries()
public final List<TarEntry> getEntries()
Gets entries of TarEntry type constituting the archive.
Returns: java.util.List<com.aspose.zip.TarEntry> - entries of TarEntry type constituting the archive
getFileEntries()
public final Iterable<IArchiveFileEntry> getFileEntries()
Gets entries of IArchiveFileEntry type constituting the tar archive.
Returns: java.lang.Iterable<com.aspose.zip.IArchiveFileEntry> - entries of IArchiveFileEntry type constituting the tar archive
save(OutputStream output)
public final void save(OutputStream output)
Saves archive to the stream provided.
try (FileOutputStream tarFile = new FileOutputStream("archive.tar")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry1", "data.bin");
archive.save(tarFile);
}
} catch (IOException ex) {
System.out.println(ex);
}
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | destination stream. |
output
must be writable |
save(OutputStream output, TarFormat format)
public final void save(OutputStream output, TarFormat format)
Saves archive to the stream provided.
try (FileOutputStream tarFile = new FileOutputStream("archive.tar")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry1", "data.bin");
archive.save(tarFile);
}
} catch (IOException ex) {
System.out.println(ex);
}
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | destination stream. |
output
must be writable |
| format | TarFormat | defines tar header format. Null value will be treated as USTar when possible |
save(String destinationFileName)
public final void save(String destinationFileName)
Saves archive to destination file provided.
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry1", "data.bin");
archive.save("myarchive.tar");
}
Parameters:
Parameter | Type | Description |
---|---|---|
destinationFileName | java.lang.String | the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten. |
It is possible to save an archive to the same path as it was loaded from. However, this is not recommended because this approach uses copying to temporary file |
save(String destinationFileName, TarFormat format)
public final void save(String destinationFileName, TarFormat format)
Saves archive to destination file provided.
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry1", "data.bin");
archive.save("myarchive.tar");
}
Parameters:
Parameter | Type | Description |
---|---|---|
destinationFileName | java.lang.String | the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten. |
It is possible to save an archive to the same path as it was loaded from. However, this is not recommended because this approach uses copying to temporary file | | format | TarFormat | defines tar header format. Null value will be treated as USTar when possible |
saveGzipped(OutputStream output)
public final void saveGzipped(OutputStream output)
Saves archive to the stream with gzip compression.
try (FileOutputStream result = new FileOutputStream("result.tar.gz")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveGzipped(result);
}
}
} catch (IOException ex) {
System.out.println(ex);
}
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | destination stream. |
output
must be writable |
saveGzipped(OutputStream output, TarFormat format)
public final void saveGzipped(OutputStream output, TarFormat format)
Saves archive to the stream with gzip compression.
try (FileOutputStream result = new FileOutputStream("result.tar.gz")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveGzipped(result);
}
}
} catch (IOException ex) {
System.out.println(ex);
}
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | destination stream. |
output
must be writable |
| format | TarFormat | defines tar header format. Null value will be treated as USTar when possible |
saveGzipped(String path)
public final void saveGzipped(String path)
Saves archive to the file by path with gzip compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveGzipped("result.tar.gz");
}
} catch (IOException ex) {
System.out.println(ex);
}
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten |
saveGzipped(String path, TarFormat format)
public final void saveGzipped(String path, TarFormat format)
Saves archive to the file by path with gzip compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveGzipped("result.tar.gz");
}
} catch (IOException ex) {
System.out.println(ex);
}
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten |
format | TarFormat | defines tar header format. Null value will be treated as USTar when possible |
saveLZMACompressed(OutputStream output)
public final void saveLZMACompressed(OutputStream output)
Saves archive to the stream with LZMA compression.
try (FileOutputStream result = new FileOutputStream("result.tar.lzma")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveLZMACompressed(result);
}
}
} catch (IOException ex) {
}
Important: tar archive is composed then compressed within this method, its content is kept internally. Beware of memory consumption.
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | destination stream. |
output
must be writable |
saveLZMACompressed(OutputStream output, TarFormat format)
public final void saveLZMACompressed(OutputStream output, TarFormat format)
Saves archive to the stream with LZMA compression.
try (FileOutputStream result = new FileOutputStream("result.tar.lzma")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveLZMACompressed(result);
}
}
} catch (IOException ex) {
}
Important: tar archive is composed then compressed within this method, its content is kept internally. Beware of memory consumption.
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | destination stream. |
output
must be writable |
| format | TarFormat | defines tar header format. Null value will be treated as USTar when possible |
saveLZMACompressed(String path)
public final void saveLZMACompressed(String path)
Saves archive to the file by path with lzma compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveLZMACompressed("result.tar.lzma");
}
} catch (IOException ex) {
}
Important: tar archive is composed then compressed within this method, its content is kept internally. Beware of memory consumption.
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten |
saveLZMACompressed(String path, TarFormat format)
public final void saveLZMACompressed(String path, TarFormat format)
Saves archive to the file by path with lzma compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveLZMACompressed("result.tar.lzma");
}
} catch (IOException ex) {
}
Important: tar archive is composed then compressed within this method, its content is kept internally. Beware of memory consumption.
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten |
format | TarFormat | defines tar header format. Null value will be treated as USTar when possible |
saveLzipped(OutputStream output)
public final void saveLzipped(OutputStream output)
Saves archive to the stream with lzip compression.
try (FileOutputStream result = new FileOutputStream("result.tar.lz")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveLzipped(result);
}
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | destination stream. |
output
must be writable |
saveLzipped(OutputStream output, TarFormat format)
public final void saveLzipped(OutputStream output, TarFormat format)
Saves archive to the stream with lzip compression.
try (FileOutputStream result = new FileOutputStream("result.tar.lz")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveLzipped(result, TarFormat.Gnu);
}
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | destination stream. |
output
must be writable |
| format | TarFormat | defines tar header format. Null value will be treated as USTar when possible |
saveLzipped(String path)
public final void saveLzipped(String path)
Saves archive to the file by path with lzip compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveLzipped("result.tar.lz");
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten |
saveLzipped(String path, TarFormat format)
public final void saveLzipped(String path, TarFormat format)
Saves archive to the file by path with lzip compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveLzipped("result.tar.lz", TarFormat.Gnu);
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten |
format | TarFormat | defines tar header format. Null value will be treated as USTar when possible |
saveXzCompressed(OutputStream output)
public final void saveXzCompressed(OutputStream output)
Saves archive to the stream with xz compression.
try (FileOutputStream result = new FileOutputStream("result.tar.xz")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveXzCompressed(result);
}
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | destination stream. |
output
The stream must be writable |
saveXzCompressed(OutputStream output, TarFormat format)
public final void saveXzCompressed(OutputStream output, TarFormat format)
Saves archive to the stream with xz compression.
try (FileOutputStream result = new FileOutputStream("result.tar.xz")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveXzCompressed(result);
}
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | destination stream. |
output
The stream must be writable |
| format | TarFormat | defines tar header format. Null value will be treated as USTar when possible |
saveXzCompressed(OutputStream output, TarFormat format, XzArchiveSettings settings)
public final void saveXzCompressed(OutputStream output, TarFormat format, XzArchiveSettings settings)
Saves archive to the stream with xz compression.
try (FileOutputStream result = new FileOutputStream("result.tar.xz")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveXzCompressed(result);
}
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | destination stream. |
output
The stream must be writable |
| format | TarFormat | defines tar header format. Null value will be treated as USTar when possible |
| settings | XzArchiveSettings | set of setting particular xz archive: dictionary size, block size, check type |
saveXzCompressed(String path)
public final void saveXzCompressed(String path)
Saves archive to the file by path with xz compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveXzCompressed("result.tar.xz");
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten |
saveXzCompressed(String path, TarFormat format)
public final void saveXzCompressed(String path, TarFormat format)
Saves archive to the file by path with xz compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveXzCompressed("result.tar.xz");
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten |
format | TarFormat | defines tar header format. Null value will be treated as USTar when possible |
saveXzCompressed(String path, TarFormat format, XzArchiveSettings settings)
public final void saveXzCompressed(String path, TarFormat format, XzArchiveSettings settings)
Saves archive to the file by path with xz compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveXzCompressed("result.tar.xz");
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten |
format | TarFormat | defines tar header format. Null value will be treated as USTar when possible |
settings | XzArchiveSettings | set of setting particular xz archive: dictionary size, block size, check type |
saveZCompressed(OutputStream output)
public final void saveZCompressed(OutputStream output)
Saves archive to the stream with Z compression.
try (FileOutputStream result = new FileOutputStream("result.tar.Z")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveZCompressed(result);
}
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | the destination stream |
saveZCompressed(OutputStream output, TarFormat format)
public final void saveZCompressed(OutputStream output, TarFormat format)
Saves archive to the stream with Z compression.
try (FileOutputStream result = new FileOutputStream("result.tar.Z")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveZCompressed(result);
}
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | the destination stream |
format | TarFormat | defines tar header format. Null value will be treated as USTar when possible |
saveZCompressed(String path)
public final void saveZCompressed(String path)
Saves archive to the file by path with Z compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveZCompressed("result.tar.Z");
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten |
saveZCompressed(String path, TarFormat format)
public final void saveZCompressed(String path, TarFormat format)
Saves archive to the file by path with Z compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveZCompressed("result.tar.Z");
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten |
format | TarFormat | defines tar header format. Null value will be treated as USTar when possible |
saveZstandard(OutputStream output)
public final void saveZstandard(OutputStream output)
Saves archive to the stream with Zstandard compression.
try (FileOutputStream result = new FileOutputStream("result.tar.zst")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveZstandard(result);
}
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | destination stream. |
output
must be writable |
saveZstandard(OutputStream output, TarFormat format)
public final void saveZstandard(OutputStream output, TarFormat format)
Saves archive to the stream with Zstandard compression.
try (FileOutputStream result = new FileOutputStream("result.tar.zst")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveZstandard(result);
}
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | destination stream. |
output
must be writable |
| format | TarFormat | defines tar header format. Null value will be treated as USTar when possible |
saveZstandard(String path)
public final void saveZstandard(String path)
Saves archive to the file by path with Zstandard compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveZstandard("result.tar.zst");
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten |
saveZstandard(String path, TarFormat format)
public final void saveZstandard(String path, TarFormat format)
Saves archive to the file by path with Zstandard compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (TarArchive archive = new TarArchive()) {
archive.createEntry("entry.bin", source);
archive.saveZstandard("result.tar.zst");
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten |
format | TarFormat | defines tar header format. Null value will be treated as USTar when possible |