CpioArchive
Inheritance: java.lang.Object
All Implemented Interfaces: com.aspose.zip.IArchive, java.lang.AutoCloseable
public class CpioArchive implements IArchive, AutoCloseable
This class represents cpio archive file.
Constructors
Constructor | Description |
---|---|
CpioArchive() | Initializes a new instance of the CpioArchive class. |
CpioArchive(InputStream sourceStream) | Initializes a new instance of the CpioArchive class and composes entries list can be extracted from the archive. |
CpioArchive(String path) | Initializes a new instance of the CpioArchive 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, String sourcePath) | Create single entry within the archive. |
createEntry(String name, String sourcePath, boolean openImmediately) | Create single entry within the archive. |
deleteEntry(CpioEntry 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. |
getEntries() | Gets entries of CpioEntry type constituting the cpio archive. |
getFileEntries() | Gets entries of IArchiveFileEntry type constituting the cpio archive. |
save(OutputStream output) | Saves archive to the stream provided. |
save(OutputStream output, CpioFormat cpioFormat) | Saves archive to the stream provided. |
save(String destinationFileName) | Saves archive to destination file provided. |
save(String destinationFileName, CpioFormat cpioFormat) | Saves archive to destination file provided. |
saveGzipped(OutputStream output) | Saves archive to the stream with gzip compression. |
saveGzipped(OutputStream output, CpioFormat cpioFormat) | Saves archive to the stream with gzip compression. |
saveGzipped(String path) | Saves archive to the file by path with gzip compression. |
saveGzipped(String path, CpioFormat cpioFormat) | Saves archive to the file by path with gzip compression. |
saveLZMACompressed(OutputStream output) | Saves the archive to the stream with LZMA compression. |
saveLZMACompressed(OutputStream output, CpioFormat cpioFormat) | Saves the archive to the stream with LZMA compression. |
saveLZMACompressed(String path) | Saves the archive to the file by path with lzma compression. |
saveLZMACompressed(String path, CpioFormat cpioFormat) | Saves the archive to the file by path with lzma compression. |
saveLzipped(OutputStream output) | Saves archive to the stream with lzip compression. |
saveLzipped(OutputStream output, CpioFormat cpioFormat) | Saves archive to the stream with lzip compression. |
saveLzipped(String path) | Saves archive to the file by path with lzip compression. |
saveLzipped(String path, CpioFormat cpioFormat) | Saves archive to the file by path with lzip compression. |
saveXzCompressed(OutputStream output) | Saves archive to the stream with xz compression. |
saveXzCompressed(OutputStream output, CpioFormat cpioFormat) | Saves archive to the stream with xz compression. |
saveXzCompressed(OutputStream output, CpioFormat cpioFormat, 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, CpioFormat cpioFormat) | Saves archive to the file by path with xz compression. |
saveXzCompressed(String path, CpioFormat cpioFormat, 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, CpioFormat cpioFormat) | Saves archive to the stream with Z compression. |
saveZCompressed(String path) | Saves archive to the file by path with Z compression. |
saveZCompressed(String path, CpioFormat cpioFormat) | Saves archive to the file by path with Z compression. |
saveZstandard(OutputStream output) | Saves archive to the stream with Zstandard compression. |
saveZstandard(OutputStream output, CpioFormat cpioFormat) | Saves archive to the stream with Zstandard compression. |
saveZstandard(String path) | Saves archive to the file by path with Zstandard compression. |
saveZstandard(String path, CpioFormat cpioFormat) | Saves archive to the file by path with Zstandard compression. |
CpioArchive()
public CpioArchive()
Initializes a new instance of the CpioArchive class.
The following example shows how to compress a file.
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("first.bin", "data.bin");
archive.save("archive.cpio");
}
CpioArchive(InputStream sourceStream)
public CpioArchive(InputStream sourceStream)
Initializes a new instance of the CpioArchive 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 (CpioArchive archive = new CpioArchive(new FileInputStream("archive.cpio"))) {
archive.extractToDirectory("C:\\extracted");
} catch (IOException ex) {
}
This constructor does not unpack any entry. See CpioEntry.open() method for unpacking.
Parameters:
Parameter | Type | Description |
---|---|---|
sourceStream | java.io.InputStream | the source of the archive |
CpioArchive(String path)
public CpioArchive(String path)
Initializes a new instance of the CpioArchive 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 (CpioArchive archive = new CpioArchive("archive.cpio")) {
archive.extractToDirectory("C:\\extracted");
} catch (IOException ex) {
}
This constructor does not unpack any entry. See CpioEntry.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 CpioArchive createEntries(File directory)
Adds to the archive all the files and directories recursively in the directory given.
try (FileOutputStream cpioFile = new FileOutputStream("archive.cpio")) {
try (CpioArchive archive = new CpioArchive()) {
archive.createEntries(new java.io.File("C:\\folder"), false);
archive.save(cpioFile);
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
directory | java.io.File | directory to compress |
Returns: CpioArchive - cpio entry instance
createEntries(File directory, boolean includeRootDirectory)
public final CpioArchive createEntries(File directory, boolean includeRootDirectory)
Adds to the archive all the files and directories recursively in the directory given.
try (FileOutputStream cpioFile = new FileOutputStream("archive.cpio")) {
try (CpioArchive archive = new CpioArchive()) {
archive.createEntries(new java.io.File("C:\\folder"), false);
archive.save(cpioFile);
}
} catch (IOException 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: CpioArchive - cpio entry instance
createEntries(String sourceDirectory)
public final CpioArchive createEntries(String sourceDirectory)
Adds to the archive all the files and directories recursively in the directory given.
try (FileOutputStream cpioFile = new FileOutputStream("archive.cpio")) {
try (CpioArchive archive = new CpioArchive()) {
archive.createEntries("C:\\folder", false);
archive.save(cpioFile);
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
sourceDirectory | java.lang.String | directory to compress |
Returns: CpioArchive - cpio entry instance
createEntries(String sourceDirectory, boolean includeRootDirectory)
public final CpioArchive createEntries(String sourceDirectory, boolean includeRootDirectory)
Adds to the archive all the files and directories recursively in the directory given.
try (FileOutputStream cpioFile = new FileOutputStream("archive.cpio")) {
try (CpioArchive archive = new CpioArchive()) {
archive.createEntries("C:\\folder", false);
archive.save(cpioFile);
}
} catch (IOException 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: CpioArchive - cpio entry instance
createEntry(String name, File file)
public final CpioEntry createEntry(String name, File file)
Create single entry within the archive.
java.io.File file = new File("data.bin");
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("test.bin", file);
archive.save("archive.cpio");
}
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: CpioEntry - cpio entry instance
createEntry(String name, File file, boolean openImmediately)
public final CpioEntry createEntry(String name, File file, boolean openImmediately)
Create single entry within the archive.
java.io.File file = new File("data.bin");
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("test.bin", file);
archive.save("archive.cpio");
}
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. |
If the file is opened immediately with openImmediately
parameter it becomes blocked until archive is disposed |
Returns: CpioEntry - cpio entry instance
createEntry(String name, InputStream source)
public final CpioEntry createEntry(String name, InputStream source)
Create single entry within the archive.
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("data.bin", new FileInputStream("data.bin"));
archive.save("archive.cpio");
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
name | java.lang.String | the name of the entry |
source | java.io.InputStream | the input stream for the entry |
Returns: CpioEntry - cpio entry instance
createEntry(String name, String sourcePath)
public final CpioEntry createEntry(String name, String sourcePath)
Create single entry within the archive.
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("first.bin", "data.bin");
archive.save("archive.cpio");
}
The entry name is solely set within name
parameter. The file name provided in sourcePath
parameter does not affect the entry name
Parameters:
Parameter | Type | Description |
---|---|---|
name | java.lang.String | the name of the entry |
sourcePath | java.lang.String | path to file to be compressed. |
Returns: CpioEntry - cpio entry instance
createEntry(String name, String sourcePath, boolean openImmediately)
public final CpioEntry createEntry(String name, String sourcePath, boolean openImmediately)
Create single entry within the archive.
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("first.bin", "data.bin");
archive.save("archive.cpio");
}
The entry name is solely set within name
parameter. The file name provided in sourcePath
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 |
sourcePath | 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: CpioEntry - cpio entry instance
deleteEntry(CpioEntry entry)
public final CpioArchive deleteEntry(CpioEntry 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 (CpioArchive archive = new CpioArchive("archive.cpio")) {
while (archive.getEntries().size() > 1)
archive.deleteEntry(archive.getEntries().get(0));
archive.save("outputCpioFile.cpio");
}
Parameters:
Parameter | Type | Description |
---|---|---|
entry | CpioEntry | the entry to remove from the entries list |
Returns: CpioArchive - cpio entry instance
deleteEntry(int entryIndex)
public final CpioArchive deleteEntry(int entryIndex)
Removes the entry from the entries list by index.
try (CpioArchive archive = new CpioArchive("two_files.cpio")) {
archive.deleteEntry(0);
archive.save("single_file.cpio");
}
Parameters:
Parameter | Type | Description |
---|---|---|
entryIndex | int | the zero-based index of the entry to remove |
Returns: CpioArchive - 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 (CpioArchive archive = new CpioArchive("archive.cpio")) {
archive.extractToDirectory("C:\\extracted");
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
destinationDirectory | java.lang.String | the path to the directory to place the extracted files in. |
If the directory does not exist, it will be created |
getEntries()
public final List<CpioEntry> getEntries()
Gets entries of CpioEntry type constituting the cpio archive.
Returns: java.util.List<com.aspose.zip.CpioEntry> - entries of CpioEntry type constituting the cpio archive.
getFileEntries()
public final Iterable<IArchiveFileEntry> getFileEntries()
Gets entries of IArchiveFileEntry type constituting the cpio archive.
Returns: java.lang.Iterable<com.aspose.zip.IArchiveFileEntry> - entries of IArchiveFileEntry type constituting the cpio archive.
save(OutputStream output)
public final void save(OutputStream output)
Saves archive to the stream provided.
try (FileOutputStream cpioFile = new FileOutputStream("archive.cpio")) {
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry1", "data.bin");
archive.save(cpioFile);
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | destination stream. |
output
must be writable |
save(OutputStream output, CpioFormat cpioFormat)
public final void save(OutputStream output, CpioFormat cpioFormat)
Saves archive to the stream provided.
try (FileOutputStream cpioFile = new FileOutputStream("archive.cpio")) {
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry1", "data.bin");
archive.save(cpioFile);
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | destination stream. |
output
must be writable |
| cpioFormat | CpioFormat | defines cpio header format |
save(String destinationFileName)
public final void save(String destinationFileName)
Saves archive to destination file provided.
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry1", "data.bin");
archive.save("archive.cpio");
}
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, CpioFormat cpioFormat)
public final void save(String destinationFileName, CpioFormat cpioFormat)
Saves archive to destination file provided.
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry1", "data.bin");
archive.save("archive.cpio");
}
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 | | cpioFormat | CpioFormat | defines cpio header format |
saveGzipped(OutputStream output)
public final void saveGzipped(OutputStream output)
Saves archive to the stream with gzip compression.
try (FileOutputStream result = new FileOutputStream("result.cpio.gz")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry.bin", source);
archive.saveGzipped(result);
}
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | destination stream. |
output
must be writable |
saveGzipped(OutputStream output, CpioFormat cpioFormat)
public final void saveGzipped(OutputStream output, CpioFormat cpioFormat)
Saves archive to the stream with gzip compression.
try (FileOutputStream result = new FileOutputStream("result.cpio.gz")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry.bin", source);
archive.saveGzipped(result);
}
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | destination stream. |
output
must be writable |
| cpioFormat | CpioFormat | defines cpio header format |
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 (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry.bin", source);
archive.saveGzipped("result.cpio.gz");
}
} 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 |
saveGzipped(String path, CpioFormat cpioFormat)
public final void saveGzipped(String path, CpioFormat cpioFormat)
Saves archive to the file by path with gzip compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry.bin", source);
archive.saveGzipped("result.cpio.gz");
}
} 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 |
cpioFormat | CpioFormat | defines cpio header format |
saveLZMACompressed(OutputStream output)
public final void saveLZMACompressed(OutputStream output)
Saves the archive to the stream with LZMA compression.
try (FileOutputStream result = new FileOutputStream("result.cpio.lzma")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry.bin", source);
archive.saveLZMACompressed(result);
}
}
} catch (IOException ex) {
}
Important: cpio 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, CpioFormat cpioFormat)
public final void saveLZMACompressed(OutputStream output, CpioFormat cpioFormat)
Saves the archive to the stream with LZMA compression.
try (FileOutputStream result = new FileOutputStream("result.cpio.lzma")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry.bin", source);
archive.saveLZMACompressed(result);
}
}
} catch (IOException ex) {
}
Important: cpio 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 |
| cpioFormat | CpioFormat | defines cpio header format |
saveLZMACompressed(String path)
public final void saveLZMACompressed(String path)
Saves the archive to the file by path with lzma compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry.bin", source);
archive.saveLZMACompressed("result.cpio.lzma");
}
} catch (IOException ex) {
}
Important: cpio 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, CpioFormat cpioFormat)
public final void saveLZMACompressed(String path, CpioFormat cpioFormat)
Saves the archive to the file by path with lzma compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry.bin", source);
archive.saveLZMACompressed("result.cpio.lzma");
}
} catch (IOException ex) {
}
Important: cpio 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 |
cpioFormat | CpioFormat | defines cpio header format |
saveLzipped(OutputStream output)
public final void saveLzipped(OutputStream output)
Saves archive to the stream with lzip compression.
try (FileOutputStream result = new FileOutputStream("result.cpio.lz")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
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, CpioFormat cpioFormat)
public final void saveLzipped(OutputStream output, CpioFormat cpioFormat)
Saves archive to the stream with lzip compression.
try (FileOutputStream result = new FileOutputStream("result.cpio.lz")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
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 |
| cpioFormat | CpioFormat | defines cpio header format |
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 (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry.bin", source);
archive.saveLzipped("result.cpio.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, CpioFormat cpioFormat)
public final void saveLzipped(String path, CpioFormat cpioFormat)
Saves archive to the file by path with lzip compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry.bin", source);
archive.saveLzipped("result.cpio.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 |
cpioFormat | CpioFormat | defines cpio header format |
saveXzCompressed(OutputStream output)
public final void saveXzCompressed(OutputStream output)
Saves archive to the stream with xz compression.
try (FileOutputStream result = new FileOutputStream("result.cpio.xz")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
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, CpioFormat cpioFormat)
public final void saveXzCompressed(OutputStream output, CpioFormat cpioFormat)
Saves archive to the stream with xz compression.
try (FileOutputStream result = new FileOutputStream("result.cpio.xz")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
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 |
| cpioFormat | CpioFormat | defines cpio header format |
saveXzCompressed(OutputStream output, CpioFormat cpioFormat, XzArchiveSettings settings)
public final void saveXzCompressed(OutputStream output, CpioFormat cpioFormat, XzArchiveSettings settings)
Saves archive to the stream with xz compression.
try (FileOutputStream result = new FileOutputStream("result.cpio.xz")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
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. |
| cpioFormat | CpioFormat | defines cpio header format |
| 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 (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry.bin", source);
archive.saveXzCompressed("result.cpio.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, CpioFormat cpioFormat)
public final void saveXzCompressed(String path, CpioFormat cpioFormat)
Saves archive to the file by path with xz compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry.bin", source);
archive.saveXzCompressed("result.cpio.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 |
cpioFormat | CpioFormat | defines cpio header format |
saveXzCompressed(String path, CpioFormat cpioFormat, XzArchiveSettings settings)
public final void saveXzCompressed(String path, CpioFormat cpioFormat, XzArchiveSettings settings)
Saves archive to the file by path with xz compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry.bin", source);
archive.saveXzCompressed("result.cpio.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 |
cpioFormat | CpioFormat | defines cpio header format |
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.cpio.Z")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry.bin", source);
archive.saveZCompressed(result);
}
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | the destination stream. |
output
must be writable |
saveZCompressed(OutputStream output, CpioFormat cpioFormat)
public final void saveZCompressed(OutputStream output, CpioFormat cpioFormat)
Saves archive to the stream with Z compression.
try (FileOutputStream result = new FileOutputStream("result.cpio.Z")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry.bin", source);
archive.saveZCompressed(result);
}
}
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
output | java.io.OutputStream | the destination stream. |
output
must be writable |
| cpioFormat | CpioFormat | defines cpio header format |
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 (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry.bin", source);
archive.saveZCompressed("result.cpio.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, CpioFormat cpioFormat)
public final void saveZCompressed(String path, CpioFormat cpioFormat)
Saves archive to the file by path with Z compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry.bin", source);
archive.saveZCompressed("result.cpio.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 |
cpioFormat | CpioFormat | d cpio header format |
saveZstandard(OutputStream output)
public final void saveZstandard(OutputStream output)
Saves archive to the stream with Zstandard compression.
try (FileOutputStream result = new FileOutputStream("result.cpio.zst")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
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, CpioFormat cpioFormat)
public final void saveZstandard(OutputStream output, CpioFormat cpioFormat)
Saves archive to the stream with Zstandard compression.
try (FileOutputStream result = new FileOutputStream("result.cpio.zst")) {
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
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 |
| cpioFormat | CpioFormat | defines cpio header format |
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 (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry.bin", source);
archive.saveZstandard("result.cpio.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, CpioFormat cpioFormat)
public final void saveZstandard(String path, CpioFormat cpioFormat)
Saves archive to the file by path with Zstandard compression.
try (FileInputStream source = new FileInputStream("data.bin")) {
try (CpioArchive archive = new CpioArchive()) {
archive.createEntry("entry.bin", source);
archive.saveZstandard("result.cpio.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 |
cpioFormat | CpioFormat | defines cpio header format |