CpioArchive

Inheritance: java.lang.Object, com.aspose.zip.ILicenseStateProvider

All Implemented Interfaces: com.aspose.zip.IArchive, java.lang.AutoCloseable

public class CpioArchive extends ILicenseStateProvider implements IArchive, AutoCloseable

This class represents cpio archive file.

Constructors

ConstructorDescription
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

MethodDescription
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.
dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
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 path by path with xz compression.
saveXzCompressed(String path, CpioFormat cpioFormat)Saves archive to the path by path with xz compression.
saveXzCompressed(String path, CpioFormat cpioFormat, XzArchiveSettings settings)Saves archive to the path by path with xz 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:

ParameterTypeDescription
sourceStreamjava.io.InputStreamthe 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:

ParameterTypeDescription
pathjava.lang.Stringthe 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:

ParameterTypeDescription
directoryjava.io.Filedirectory 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:

ParameterTypeDescription
directoryjava.io.Filedirectory to compress
includeRootDirectorybooleanindicates 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:

ParameterTypeDescription
sourceDirectoryjava.lang.Stringdirectory 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:

ParameterTypeDescription
sourceDirectoryjava.lang.Stringdirectory to compress
includeRootDirectorybooleanindicates 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:

ParameterTypeDescription
namejava.lang.Stringthe name of the entry
filejava.io.Filethe 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:

ParameterTypeDescription
namejava.lang.Stringthe name of the entry
filejava.io.Filethe metadata of file or folder to be compressed
openImmediatelybooleantrue 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:

ParameterTypeDescription
namejava.lang.Stringthe name of the entry
sourcejava.io.InputStreamthe 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:

ParameterTypeDescription
namejava.lang.Stringthe name of the entry
sourcePathjava.lang.Stringpath 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:

ParameterTypeDescription
namejava.lang.Stringthe name of the entry
sourcePathjava.lang.Stringpath to file to be compressed.
openImmediatelybooleantrue 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:

ParameterTypeDescription
entryCpioEntrythe 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:

ParameterTypeDescription
entryIndexintthe zero-based index of the entry to remove

Returns: CpioArchive - the archive with the entry deleted

dispose()

public final void dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

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:

ParameterTypeDescription
destinationDirectoryjava.lang.Stringthe 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:

ParameterTypeDescription
outputjava.io.OutputStreamdestination 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:

ParameterTypeDescription
outputjava.io.OutputStreamdestination 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:

ParameterTypeDescription
destinationFileNamejava.lang.Stringthe 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:

ParameterTypeDescription
destinationFileNamejava.lang.Stringthe 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:

ParameterTypeDescription
outputjava.io.OutputStreamdestination 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:

ParameterTypeDescription
outputjava.io.OutputStreamdestination 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:

ParameterTypeDescription
pathjava.lang.Stringthe 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:

ParameterTypeDescription
pathjava.lang.Stringthe path of the archive to be created. If the specified file name points to an existing file, it will be overwritten
cpioFormatCpioFormatdefines 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:

ParameterTypeDescription
outputjava.io.OutputStreamdestination 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:

ParameterTypeDescription
outputjava.io.OutputStreamdestination 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:

ParameterTypeDescription
pathjava.lang.Stringthe 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:

ParameterTypeDescription
pathjava.lang.Stringthe path of the archive to be created. If the specified file name points to an existing file, it will be overwritten
cpioFormatCpioFormatdefines 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:

ParameterTypeDescription
outputjava.io.OutputStreamdestination 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:

ParameterTypeDescription
outputjava.io.OutputStreamdestination 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:

ParameterTypeDescription
pathjava.lang.Stringthe 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:

ParameterTypeDescription
pathjava.lang.Stringthe path of the archive to be created. If the specified file name points to an existing file, it will be overwritten
cpioFormatCpioFormatdefines 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:

ParameterTypeDescription
outputjava.io.OutputStreamdestination stream.

outputThe 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:

ParameterTypeDescription
outputjava.io.OutputStreamdestination stream.

outputThe 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:

ParameterTypeDescription
outputjava.io.OutputStreamdestination stream.

outputThe 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 path 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:

ParameterTypeDescription
pathjava.lang.Stringthe 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 path 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:

ParameterTypeDescription
pathjava.lang.Stringthe path of the archive to be created. If the specified file name points to an existing file, it will be overwritten
cpioFormatCpioFormatdefines cpio header format

saveXzCompressed(String path, CpioFormat cpioFormat, XzArchiveSettings settings)

public final void saveXzCompressed(String path, CpioFormat cpioFormat, XzArchiveSettings settings)

Saves archive to the path 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:

ParameterTypeDescription
pathjava.lang.Stringthe path of the archive to be created. If the specified file name points to an existing file, it will be overwritten
cpioFormatCpioFormatdefines cpio header format
settingsXzArchiveSettingsset of setting particular xz archive: dictionary size, block size, check type

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:

ParameterTypeDescription
outputjava.io.OutputStreamdestination 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:

ParameterTypeDescription
outputjava.io.OutputStreamdestination 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:

ParameterTypeDescription
pathjava.lang.Stringthe 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:

ParameterTypeDescription
pathjava.lang.Stringthe path of the archive to be created. If the specified file name points to an existing file, it will be overwritten
cpioFormatCpioFormatdefines cpio header format