Class CpioArchive

    • Constructor Detail

      • 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

        public CpioArchive​(InputStream sourceStream)

        Initializes a new instance of the CpioArchive class and composes an entry list can be extracted from the archive.

        The following example shows how to extract all 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:
        sourceStream - the source of the archive
        Throws:
        com.aspose.ms.System.ArgumentNullException - sourceStream is null.
        com.aspose.ms.System.ArgumentException - sourceStream is not seekable.
        com.aspose.ms.System.IO.InvalidDataException - sourceStream is not valid cpio archive.
      • CpioArchive

        public CpioArchive​(String path)

        Initializes a new instance of the CpioArchive class and composes an entry list can be extracted from the archive.

        The following example shows how to extract all 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:
        path - the path to the archive file
        Throws:
        com.aspose.ms.System.ArgumentNullException - path is null.
        com.aspose.ms.System.SecurityException - The caller does not have the required permission to access.
        com.aspose.ms.System.ArgumentException - The path is empty, contains only white spaces, or contains invalid characters.
        com.aspose.ms.System.IO.PathTooLongException - The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
        com.aspose.ms.System.NotSupportedException - File at path contains a colon (:) in the middle of the string.
        com.aspose.ms.System.IO.FileNotFoundException - The file is not found.
        com.aspose.ms.System.IO.DirectoryNotFoundException - The specified path is invalid, such as being on an unmapped drive.
        com.aspose.ms.System.IO.IOException - The file is already open.
    • Method Detail

      • getEntries

        public final List<CpioEntry> getEntries()

        Gets entries of CpioEntry type constituting the cpio archive.

        Returns:
        entries of CpioEntry type constituting the cpio archive.
      • getFormat

        public final ArchiveFormat getFormat()

        Gets the archive format.

        Specified by:
        getFormat in interface IArchive
        Returns:
        the archive format
      • createEntries

        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:
        sourceDirectory - directory to compress
        Returns:
        cpio entry instance
        Throws:
        com.aspose.ms.System.ArgumentNullException - sourceDirectory is null.
        com.aspose.ms.System.SecurityException - The caller does not have the required permission to access sourceDirectory.
        com.aspose.ms.System.ArgumentException - sourceDirectory contains invalid characters such as ", <, >, or |.
        com.aspose.ms.System.IO.PathTooLongException - The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. The specified path, file name, or both are too long.
        com.aspose.ms.System.IO.IOException - sourceDirectory stands for a file, not for a directory.
      • createEntries

        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:
        sourceDirectory - directory to compress
        includeRootDirectory - indicates whether to include the root directory itself or not
        Returns:
        cpio entry instance
        Throws:
        com.aspose.ms.System.ArgumentNullException - sourceDirectory is null.
        com.aspose.ms.System.SecurityException - The caller does not have the required permission to access sourceDirectory.
        com.aspose.ms.System.ArgumentException - sourceDirectory contains invalid characters such as ", <, >, or |.
        com.aspose.ms.System.IO.PathTooLongException - The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. The specified path, file name, or both are too long.
        com.aspose.ms.System.IO.IOException - sourceDirectory stands for a file, not for a directory.
      • createEntries

        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:
        directory - directory to compress
        Returns:
        cpio entry instance
        Throws:
        com.aspose.ms.System.ArgumentNullException - directory is null.
        com.aspose.ms.System.SecurityException - The caller does not have the required permission to access directory.
        com.aspose.ms.System.IO.IOException - directory stands for a file, not for a directory.
      • createEntries

        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:
        directory - directory to compress
        includeRootDirectory - indicates whether to include the root directory itself or not
        Returns:
        cpio entry instance
        Throws:
        com.aspose.ms.System.ArgumentNullException - directory is null.
        com.aspose.ms.System.SecurityException - The caller does not have the required permission to access directory.
        com.aspose.ms.System.IO.IOException - directory stands for a file, not for a directory.
      • createEntry

        public final CpioEntry createEntry​(String name,
                                           File file)

        Creates a 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:
        name - the name of the entry
        file - the metadata of file or folder to be compressed
        Returns:
        cpio entry instance
        Throws:
        com.aspose.ms.System.ArgumentNullException - name is null.
        com.aspose.ms.System.ArgumentException - name is empty.
        com.aspose.ms.System.ArgumentNullException - file is null.
      • createEntry

        public final CpioEntry createEntry​(String name,
                                           File file,
                                           boolean openImmediately)

        Creates a 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:
        name - the name of the entry
        file - the metadata of file or folder to be compressed
        openImmediately - 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:
        cpio entry instance
        Throws:
        com.aspose.ms.System.ArgumentNullException - name is null.
        com.aspose.ms.System.ArgumentException - name is empty.
        com.aspose.ms.System.ArgumentNullException - file is null.
      • createEntry

        public final CpioEntry createEntry​(String name,
                                           String sourcePath)

        Creates a 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:
        name - the name of the entry
        sourcePath - path to file to be compressed.
        Returns:
        cpio entry instance
        Throws:
        com.aspose.ms.System.ArgumentNullException - sourcePath is null.
        com.aspose.ms.System.SecurityException - The caller does not have the required permission to access.
        com.aspose.ms.System.ArgumentException - The sourcePath is empty, contains only white spaces, or contains invalid characters. - or - File name, as a part of name, exceeds 100 symbols.
        com.aspose.ms.System.IO.PathTooLongException - The specified sourcePath, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. - or - name is too long for cpio.
        com.aspose.ms.System.NotSupportedException - File at sourcePath contains a colon (:) in the middle of the string.
      • createEntry

        public final CpioEntry createEntry​(String name,
                                           String sourcePath,
                                           boolean openImmediately)

        Creates a 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:
        name - the name of the entry
        sourcePath - path to file to be compressed.
        openImmediately - true, if open the file immediately, otherwise open the file on archive saving.
        Returns:
        cpio entry instance
        Throws:
        com.aspose.ms.System.ArgumentNullException - sourcePath is null.
        com.aspose.ms.System.SecurityException - The caller does not have the required permission to access.
        com.aspose.ms.System.ArgumentException - The sourcePath is empty, contains only white spaces, or contains invalid characters. - or - File name, as a part of name, exceeds 100 symbols.
        com.aspose.ms.System.IO.PathTooLongException - The specified sourcePath, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. - or - name is too long for cpio.
        com.aspose.ms.System.NotSupportedException - File at sourcePath contains a colon (:) in the middle of the string.
      • createEntry

        public final CpioEntry createEntry​(String name,
                                           InputStream source)

        Creates a 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:
        name - the name of the entry
        source - the input stream for the entry
        Returns:
        cpio entry instance
        Throws:
        com.aspose.ms.System.ArgumentNullException - name is null.
        com.aspose.ms.System.ArgumentNullException - source is null.
        com.aspose.ms.System.ArgumentException - name is empty.
      • deleteEntry

        public final CpioArchive deleteEntry​(CpioEntry entry)

        Removes the first occurrence of a specific entry from the entry 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:
        entry - the entry to remove from the entries list
        Returns:
        cpio entry instance
        Throws:
        com.aspose.ms.System.ArgumentNullException - entry is null.
      • deleteEntry

        public final CpioArchive deleteEntry​(int entryIndex)

        Removes the entry from the entry list by index.

        
             try (CpioArchive archive = new CpioArchive("two_files.cpio")) {
                 archive.deleteEntry(0);
                 archive.save("single_file.cpio");
             }
         
        Parameters:
        entryIndex - the zero-based index of the entry to remove
        Returns:
        the archive with the entry deleted
        Throws:
        com.aspose.ms.System.ArgumentOutOfRangeException - entryIndex is less than 0.-or- entryIndex is equal to or greater than Entries count.
      • extractToDirectory

        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) {
             }
         
        Specified by:
        extractToDirectory in interface IArchive
        Parameters:
        destinationDirectory - the path to the directory to place the extracted files in.

        If the directory does not exist, it will be created

        Throws:
        com.aspose.ms.System.ArgumentNullException - Path is null
        com.aspose.ms.System.IO.PathTooLongException - The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
        com.aspose.ms.System.SecurityException - The caller does not have the required permission to access the existing directory.
        com.aspose.ms.System.NotSupportedException - If the directory does not exist, the path contains a colon character (:) that is not part of a drive label ("C:\").
        com.aspose.ms.System.ArgumentException - path is a zero-length string, contains only white space, or contains one or more invalid characters.
        com.aspose.ms.System.IO.IOException - The directory specified by path is a file. -or- The network name is not known.
      • save

        public final void save​(String destinationFileName)

        Saves archive to the destination file provided.

        
             try (CpioArchive archive = new CpioArchive()) {
                 archive.createEntry("entry1", "data.bin");
                 archive.save("archive.cpio");
             }
         
        Parameters:
        destinationFileName - 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 a temporary file

        Throws:
        com.aspose.ms.System.ArgumentException - destinationFileName is a zero-length string, contains only white space, or contains one or more invalid characters.
        com.aspose.ms.System.ArgumentNullException - destinationFileName is null.
        com.aspose.ms.System.IO.PathTooLongException - The specified destinationFileName, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
        com.aspose.ms.System.IO.DirectoryNotFoundException - The specified destinationFileName is invalid, (for example, it is on an unmapped drive).
        com.aspose.ms.System.IO.IOException - An I/O error occurred while opening the file.
        com.aspose.ms.System.NotSupportedException - destinationFileName is in an invalid format.
      • save

        public final void save​(String destinationFileName,
                               CpioFormat cpioFormat)

        Saves archive to the destination file provided.

        
             try (CpioArchive archive = new CpioArchive()) {
                 archive.createEntry("entry1", "data.bin");
                 archive.save("archive.cpio");
             }
         
        Parameters:
        destinationFileName - 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 a temporary file

        cpioFormat - defines cpio header format
        Throws:
        com.aspose.ms.System.ArgumentException - destinationFileName is a zero-length string, contains only white space, or contains one or more invalid characters.
        com.aspose.ms.System.ArgumentNullException - destinationFileName is null.
        com.aspose.ms.System.IO.PathTooLongException - The specified destinationFileName, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
        com.aspose.ms.System.IO.DirectoryNotFoundException - The specified destinationFileName is invalid, (for example, it is on an unmapped drive).
        com.aspose.ms.System.IO.IOException - An I/O error occurred while opening the file.
        com.aspose.ms.System.NotSupportedException - destinationFileName is in an invalid format.
      • save

        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:
        output - destination stream.

        output must be writable

        Throws:
        com.aspose.ms.System.ArgumentNullException - output is null.
        com.aspose.ms.System.ArgumentException - output is not writable. - or - output is the same stream we extract from. - or - It is impossible to save archive in cpioFormat due to format restrictions.
      • save

        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:
        output - destination stream.

        output must be writable

        cpioFormat - defines cpio header format
        Throws:
        com.aspose.ms.System.ArgumentNullException - output is null.
        com.aspose.ms.System.ArgumentException - output is not writable. - or - output is the same stream we extract from. - or - It is impossible to save archive in cpioFormat due to format restrictions.
      • saveGzipped

        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:
        output - destination stream.

        output must be writable

        Throws:
        com.aspose.ms.System.ArgumentNullException - output is null.
        com.aspose.ms.System.ArgumentException - output is not writable.
      • saveGzipped

        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:
        output - destination stream.

        output must be writable

        cpioFormat - defines cpio header format
        Throws:
        com.aspose.ms.System.ArgumentNullException - output is null.
        com.aspose.ms.System.ArgumentException - output is not writable.
      • saveGzipped

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

        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:
        path - the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten
        cpioFormat - defines cpio header format
      • saveLzipped

        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:
        output - destination stream.

        output must be writable

        Throws:
        com.aspose.ms.System.ArgumentNullException - output is null.
        com.aspose.ms.System.ArgumentException - output is not writable.
      • saveLzipped

        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:
        output - destination stream.

        output must be writable

        cpioFormat - defines cpio header format
        Throws:
        com.aspose.ms.System.ArgumentNullException - output is null.
        com.aspose.ms.System.ArgumentException - output is not writable.
      • saveLzipped

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

        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:
        path - the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten
        cpioFormat - defines cpio header format
      • saveLZMACompressed

        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:
        output - destination stream.

        output must be writable

      • saveLZMACompressed

        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:
        output - destination stream.

        output must be writable

        cpioFormat - defines cpio header format
      • saveLZMACompressed

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

        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:
        path - the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten
        cpioFormat - defines cpio header format
      • saveXzCompressed

        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:
        output - destination stream.

        outputThe stream must be writable

        Throws:
        com.aspose.ms.System.ArgumentNullException - output is null.
        com.aspose.ms.System.ArgumentException - output is not writable.
      • saveXzCompressed

        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:
        output - destination stream.

        outputThe stream must be writable

        cpioFormat - defines cpio header format
        Throws:
        com.aspose.ms.System.ArgumentNullException - output is null.
        com.aspose.ms.System.ArgumentException - output is not writable.
      • saveXzCompressed

        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:
        output - destination stream.

        outputThe stream must be writable.

        cpioFormat - defines cpio header format
        settings - set of setting particular xz archive: dictionary size, block size, check type
        Throws:
        com.aspose.ms.System.ArgumentNullException - output is null.
        com.aspose.ms.System.ArgumentException - output is not writable.
      • saveXzCompressed

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

        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:
        path - the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten
        cpioFormat - defines cpio header format
      • saveXzCompressed

        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:
        path - the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten
        cpioFormat - defines cpio header format
        settings - set of setting particular xz archive: dictionary size, block size, check type
      • saveZCompressed

        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:
        output - the destination stream.

        output must be writable

        Throws:
        com.aspose.ms.System.ArgumentNullException - output is null.
        com.aspose.ms.System.ArgumentException - output is not writable.
      • saveZCompressed

        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:
        output - the destination stream.

        output must be writable

        cpioFormat - defines cpio header format
        Throws:
        com.aspose.ms.System.ArgumentNullException - output is null.
        com.aspose.ms.System.ArgumentException - output is not writable.
      • saveZCompressed

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

        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:
        path - the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten
        cpioFormat - d cpio header format
      • saveZstandard

        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:
        output - destination stream.

        output must be writable

        Throws:
        com.aspose.ms.System.ArgumentNullException - output is null.
        com.aspose.ms.System.ArgumentException - output is not writable.
      • saveZstandard

        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:
        output - destination stream.

        output must be writable

        cpioFormat - defines cpio header format
        Throws:
        com.aspose.ms.System.ArgumentNullException - output is null.
        com.aspose.ms.System.ArgumentException - output is not writable.
      • saveZstandard

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

        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:
        path - the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten
        cpioFormat - defines cpio header format