Class ArchiveFactory
- java.lang.Object
-
- com.aspose.zip.ArchiveFactory
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcompressDirectory(String path, String outputFileName, ArchiveFormat archiveFormat)Compresses the specified directory into an archive file using the provided archive format.static IArchivegetArchive(InputStream stream)Detects the archive format and creates the appropriateIArchiveobject according to the type of archive specified by the given stream.static IArchivegetArchive(InputStream stream, String password)Detects the archive format and creates the appropriateIArchiveobject according to the type of encrypted archive specified by the given stream.static IArchivegetArchive(String path)Detects the archive format and creates the appropriateIArchiveobject according to the type of archive specified by the given path.
-
-
-
Method Detail
-
getArchive
public static IArchive getArchive(String path)
Detects the archive format and creates the appropriate
IArchiveobject according to the type of archive specified by the given path.- Parameters:
path- the path to the archive to be analyzed- Returns:
- an
IArchiveobject representing the archive
-
getArchive
public static IArchive getArchive(InputStream stream)
Detects the archive format and creates the appropriate
IArchiveobject according to the type of archive specified by the given stream.- Parameters:
stream- the stream containing the archive data- Returns:
- an
IArchiveobject representing the archive
-
getArchive
public static IArchive getArchive(InputStream stream, String password)
Detects the archive format and creates the appropriate
IArchiveobject according to the type of encrypted archive specified by the given stream.- Parameters:
stream- the stream containing the archive datapassword- password to decrypt an encrypted archive- Returns:
- an
IArchiveobject representing the archive
-
compressDirectory
public static void compressDirectory(String path, String outputFileName, ArchiveFormat archiveFormat)
Compresses the specified directory into an archive file using the provided archive format.
Here is an example of how to use the CompressDirectory method:String directoryPath = "C:\\path\\to\\your\\directory"; ArchiveFormat format = ArchiveFormat.Zip; ArchiveFactory.compressDirectory(directoryPath, "result", format); // This will create a ZIP file with the contents of the directory at the specified path.This method will create an archive file at the location specified by the
pathparameter. The name of the archive file will typically be the directory name followed by the appropriate file extension based on thearchiveFormat. The directory itself is not modified or deleted.- Parameters:
path- the path to the directory that will be compressedoutputFileName- destination file namearchiveFormat- the format of the archive to create (e.g., zip, rar, tar, etc.)- Throws:
com.aspose.ms.System.IO.DirectoryNotFoundException- Thrown if the directory specified bypathdoes not exist.com.aspose.ms.System.ArgumentException- Thrown ifpathis null or an empty string.com.aspose.ms.System.NotSupportedException- Thrown if the specifiedarchiveFormatis not supported or recognized.
-
-