Class CpioArchive
- java.lang.Object
-
- com.aspose.zip.CpioArchive
-
- All Implemented Interfaces:
IArchive,AutoCloseable
public class CpioArchive extends Object implements IArchive, AutoCloseable
This class represents cpio archive file.
-
-
Constructor Summary
Constructors Constructor Description CpioArchive()Initializes a new instance of theCpioArchiveclass.CpioArchive(InputStream sourceStream)Initializes a new instance of theCpioArchiveclass and composes an entry list can be extracted from the archive.CpioArchive(String path)Initializes a new instance of theCpioArchiveclass and composes an entry list can be extracted from the archive.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()CpioArchivecreateEntries(File directory)Adds to the archive all the files and directories recursively in the directory given.CpioArchivecreateEntries(File directory, boolean includeRootDirectory)Adds to the archive all the files and directories recursively in the directory given.CpioArchivecreateEntries(String sourceDirectory)Adds to the archive all the files and directories recursively in the directory given.CpioArchivecreateEntries(String sourceDirectory, boolean includeRootDirectory)Adds to the archive all the files and directories recursively in the directory given.CpioEntrycreateEntry(String name, File file)Creates a single entry within the archive.CpioEntrycreateEntry(String name, File file, boolean openImmediately)Creates a single entry within the archive.CpioEntrycreateEntry(String name, InputStream source)Creates a single entry within the archive.CpioEntrycreateEntry(String name, String sourcePath)Creates a single entry within the archive.CpioEntrycreateEntry(String name, String sourcePath, boolean openImmediately)Creates a single entry within the archive.CpioArchivedeleteEntry(int entryIndex)Removes the entry from the entry list by index.CpioArchivedeleteEntry(CpioEntry entry)Removes the first occurrence of a specific entry from the entry list.voidextractToDirectory(String destinationDirectory)Extracts all the files in the archive to the directory provided.List<CpioEntry>getEntries()Gets entries ofCpioEntrytype constituting the cpio archive.Iterable<IArchiveFileEntry>getFileEntries()Gets entries ofIArchiveFileEntrytype constituting the cpio archive.ArchiveFormatgetFormat()Gets the archive format.voidsave(OutputStream output)Saves archive to the stream provided.voidsave(OutputStream output, CpioFormat cpioFormat)Saves archive to the stream provided.voidsave(String destinationFileName)Saves archive to the destination file provided.voidsave(String destinationFileName, CpioFormat cpioFormat)Saves archive to the destination file provided.voidsaveGzipped(OutputStream output)Saves archive to the stream with gzip compression.voidsaveGzipped(OutputStream output, CpioFormat cpioFormat)Saves archive to the stream with gzip compression.voidsaveGzipped(String path)Saves archive to the file by path with gzip compression.voidsaveGzipped(String path, CpioFormat cpioFormat)Saves archive to the file by path with gzip compression.voidsaveLzipped(OutputStream output)Saves archive to the stream with lzip compression.voidsaveLzipped(OutputStream output, CpioFormat cpioFormat)Saves archive to the stream with lzip compression.voidsaveLzipped(String path)Saves archive to the file by path with lzip compression.voidsaveLzipped(String path, CpioFormat cpioFormat)Saves archive to the file by path with lzip compression.voidsaveLZMACompressed(OutputStream output)Saves the archive to the stream with LZMA compression.voidsaveLZMACompressed(OutputStream output, CpioFormat cpioFormat)Saves the archive to the stream with LZMA compression.voidsaveLZMACompressed(String path)Saves the archive to the file by path with lzma compression.voidsaveLZMACompressed(String path, CpioFormat cpioFormat)Saves the archive to the file by path with lzma compression.voidsaveXzCompressed(OutputStream output)Saves archive to the stream with xz compression.voidsaveXzCompressed(OutputStream output, CpioFormat cpioFormat)Saves archive to the stream with xz compression.voidsaveXzCompressed(OutputStream output, CpioFormat cpioFormat, XzArchiveSettings settings)Saves archive to the stream with xz compression.voidsaveXzCompressed(String path)Saves archive to the file by path with xz compression.voidsaveXzCompressed(String path, CpioFormat cpioFormat)Saves archive to the file by path with xz compression.voidsaveXzCompressed(String path, CpioFormat cpioFormat, XzArchiveSettings settings)Saves archive to the file by path with xz compression.voidsaveZCompressed(OutputStream output)Saves archive to the stream with Z compression.voidsaveZCompressed(OutputStream output, CpioFormat cpioFormat)Saves archive to the stream with Z compression.voidsaveZCompressed(String path)Saves archive to the file by path with Z compression.voidsaveZCompressed(String path, CpioFormat cpioFormat)Saves archive to the file by path with Z compression.voidsaveZstandard(OutputStream output)Saves archive to the stream with Zstandard compression.voidsaveZstandard(OutputStream output, CpioFormat cpioFormat)Saves archive to the stream with Zstandard compression.voidsaveZstandard(String path)Saves archive to the file by path with Zstandard compression.voidsaveZstandard(String path, CpioFormat cpioFormat)Saves archive to the file by path with Zstandard compression.
-
-
-
Constructor Detail
-
CpioArchive
public CpioArchive()
Initializes a new instance of the
CpioArchiveclass.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
CpioArchiveclass 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-sourceStreamis null.com.aspose.ms.System.ArgumentException-sourceStreamis not seekable.com.aspose.ms.System.IO.InvalidDataException-sourceStreamis not valid cpio archive.
-
CpioArchive
public CpioArchive(String path)
Initializes a new instance of the
CpioArchiveclass 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-pathis null.com.aspose.ms.System.SecurityException- The caller does not have the required permission to access.com.aspose.ms.System.ArgumentException- Thepathis empty, contains only white spaces, or contains invalid characters.com.aspose.ms.System.IO.PathTooLongException- The specifiedpath, 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 atpathcontains 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
CpioEntrytype constituting the cpio archive.- Returns:
- entries of
CpioEntrytype constituting the cpio archive.
-
getFileEntries
public final Iterable<IArchiveFileEntry> getFileEntries()
Gets entries of
IArchiveFileEntrytype constituting the cpio archive.- Specified by:
getFileEntriesin interfaceIArchive- Returns:
- entries of
IArchiveFileEntrytype constituting the cpio archive.
-
getFormat
public final ArchiveFormat getFormat()
Gets 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-sourceDirectoryis null.com.aspose.ms.System.SecurityException- The caller does not have the required permission to accesssourceDirectory.com.aspose.ms.System.ArgumentException-sourceDirectorycontains 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-sourceDirectorystands 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 compressincludeRootDirectory- indicates whether to include the root directory itself or not- Returns:
- cpio entry instance
- Throws:
com.aspose.ms.System.ArgumentNullException-sourceDirectoryis null.com.aspose.ms.System.SecurityException- The caller does not have the required permission to accesssourceDirectory.com.aspose.ms.System.ArgumentException-sourceDirectorycontains 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-sourceDirectorystands 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-directoryis null.com.aspose.ms.System.SecurityException- The caller does not have the required permission to accessdirectory.com.aspose.ms.System.IO.IOException-directorystands 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 compressincludeRootDirectory- indicates whether to include the root directory itself or not- Returns:
- cpio entry instance
- Throws:
com.aspose.ms.System.ArgumentNullException-directoryis null.com.aspose.ms.System.SecurityException- The caller does not have the required permission to accessdirectory.com.aspose.ms.System.IO.IOException-directorystands 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 entryfile- the metadata of file or folder to be compressed- Returns:
- cpio entry instance
- Throws:
com.aspose.ms.System.ArgumentNullException-nameis null.com.aspose.ms.System.ArgumentException-nameis empty.com.aspose.ms.System.ArgumentNullException-fileis 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 entryfile- the metadata of file or folder to be compressedopenImmediately- true, if open the file immediately, otherwise open the file on archive saving.If the file is opened immediately with
openImmediatelyparameter it becomes blocked until archive is disposed- Returns:
- cpio entry instance
- Throws:
com.aspose.ms.System.ArgumentNullException-nameis null.com.aspose.ms.System.ArgumentException-nameis empty.com.aspose.ms.System.ArgumentNullException-fileis 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
nameparameter. The file name provided insourcePathparameter does not affect the entry name- Parameters:
name- the name of the entrysourcePath- path to file to be compressed.- Returns:
- cpio entry instance
- Throws:
com.aspose.ms.System.ArgumentNullException-sourcePathis null.com.aspose.ms.System.SecurityException- The caller does not have the required permission to access.com.aspose.ms.System.ArgumentException- ThesourcePathis empty, contains only white spaces, or contains invalid characters. - or - File name, as a part ofname, exceeds 100 symbols.com.aspose.ms.System.IO.PathTooLongException- The specifiedsourcePath, 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 -nameis too long for cpio.com.aspose.ms.System.NotSupportedException- File atsourcePathcontains 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
nameparameter. The file name provided insourcePathparameter does not affect the entry nameIf the file is opened immediately with
openImmediatelyparameter it becomes blocked until archive is disposed- Parameters:
name- the name of the entrysourcePath- 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-sourcePathis null.com.aspose.ms.System.SecurityException- The caller does not have the required permission to access.com.aspose.ms.System.ArgumentException- ThesourcePathis empty, contains only white spaces, or contains invalid characters. - or - File name, as a part ofname, exceeds 100 symbols.com.aspose.ms.System.IO.PathTooLongException- The specifiedsourcePath, 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 -nameis too long for cpio.com.aspose.ms.System.NotSupportedException- File atsourcePathcontains 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 entrysource- the input stream for the entry- Returns:
- cpio entry instance
- Throws:
com.aspose.ms.System.ArgumentNullException-nameis null.com.aspose.ms.System.ArgumentNullException-sourceis null.com.aspose.ms.System.ArgumentException-nameis 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-entryis 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-entryIndexis less than 0.-or-entryIndexis equal to or greater thanEntriescount.
-
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:
extractToDirectoryin interfaceIArchive- 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 nullcom.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-destinationFileNameis a zero-length string, contains only white space, or contains one or more invalid characters.com.aspose.ms.System.ArgumentNullException-destinationFileNameis null.com.aspose.ms.System.IO.PathTooLongException- The specifieddestinationFileName, 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 specifieddestinationFileNameis 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-destinationFileNameis 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-destinationFileNameis a zero-length string, contains only white space, or contains one or more invalid characters.com.aspose.ms.System.ArgumentNullException-destinationFileNameis null.com.aspose.ms.System.IO.PathTooLongException- The specifieddestinationFileName, 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 specifieddestinationFileNameis 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-destinationFileNameis 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.outputmust be writable- Throws:
com.aspose.ms.System.ArgumentNullException-outputis null.com.aspose.ms.System.ArgumentException-outputis not writable. - or -outputis the same stream we extract from. - or - It is impossible to save archive incpioFormatdue 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.outputmust be writablecpioFormat- defines cpio header format- Throws:
com.aspose.ms.System.ArgumentNullException-outputis null.com.aspose.ms.System.ArgumentException-outputis not writable. - or -outputis the same stream we extract from. - or - It is impossible to save archive incpioFormatdue 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.outputmust be writable- Throws:
com.aspose.ms.System.ArgumentNullException-outputis null.com.aspose.ms.System.ArgumentException-outputis 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.outputmust be writablecpioFormat- defines cpio header format- Throws:
com.aspose.ms.System.ArgumentNullException-outputis null.com.aspose.ms.System.ArgumentException-outputis 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 overwrittencpioFormat- 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.outputmust be writable- Throws:
com.aspose.ms.System.ArgumentNullException-outputis null.com.aspose.ms.System.ArgumentException-outputis 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.outputmust be writablecpioFormat- defines cpio header format- Throws:
com.aspose.ms.System.ArgumentNullException-outputis null.com.aspose.ms.System.ArgumentException-outputis 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 overwrittencpioFormat- 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.outputmust 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.outputmust be writablecpioFormat- 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 overwrittencpioFormat- 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-outputis null.com.aspose.ms.System.ArgumentException-outputis 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 writablecpioFormat- defines cpio header format- Throws:
com.aspose.ms.System.ArgumentNullException-outputis null.com.aspose.ms.System.ArgumentException-outputis 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 formatsettings- set of setting particular xz archive: dictionary size, block size, check type- Throws:
com.aspose.ms.System.ArgumentNullException-outputis null.com.aspose.ms.System.ArgumentException-outputis 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 overwrittencpioFormat- 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 overwrittencpioFormat- defines cpio header formatsettings- 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.outputmust be writable- Throws:
com.aspose.ms.System.ArgumentNullException-outputis null.com.aspose.ms.System.ArgumentException-outputis 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.outputmust be writablecpioFormat- defines cpio header format- Throws:
com.aspose.ms.System.ArgumentNullException-outputis null.com.aspose.ms.System.ArgumentException-outputis 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 overwrittencpioFormat- 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.outputmust be writable- Throws:
com.aspose.ms.System.ArgumentNullException-outputis null.com.aspose.ms.System.ArgumentException-outputis 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.outputmust be writablecpioFormat- defines cpio header format- Throws:
com.aspose.ms.System.ArgumentNullException-outputis null.com.aspose.ms.System.ArgumentException-outputis 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 overwrittencpioFormat- defines cpio header format
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceIArchive
-
-