Package com.aspose.zip
Class XarFileEntry
- java.lang.Object
-
- com.aspose.zip.XarEntry
-
- com.aspose.zip.XarFileEntry
-
- All Implemented Interfaces:
IArchiveFileEntry
public final class XarFileEntry extends XarEntry implements IArchiveFileEntry
Represents file entry within xar archive.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidextract(OutputStream destination)Extracts the entry to the stream provided.Fileextract(String path)Extracts the entry to the filesystem by the path provided.Event<ProgressEventArgs>getCompressionProgressed()Gets an event that is raised when a portion of raw stream compressed.LonggetLength()Gets the length of the entry in bytes.InputStreamopen()Opens the entry for extraction and provides a stream with entry content.voidsetCompressionProgressed(Event<ProgressEventArgs> value)Sets an event that is raised when a portion of raw stream compressed.-
Methods inherited from class com.aspose.zip.XarEntry
getCreationTime, getFullPath, getLastAccessTime, getLastWriteTime, getModificationTime, getName, getParent, isDirectory, toString
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.aspose.zip.IArchiveFileEntry
getName
-
-
-
-
Method Detail
-
getLength
public final Long getLength()
Gets the length of the entry in bytes.
- Specified by:
getLengthin interfaceIArchiveFileEntry- Returns:
- the length of the entry in bytes
-
getCompressionProgressed
public final Event<ProgressEventArgs> getCompressionProgressed()
Gets an event that is raised when a portion of raw stream compressed.
archive.getEntries().get(0).setCompressionProgressed(new Event<ProgressEventArgs>() { public void invoke(Object sender, ProgressEventArgs progressEventArgs) { int percent = (int) ((100 * (long) progressEventArgs.getProceededBytes()) / entrySourceFile.length()); } });Event sender is an
XarFileEntryinstance.- Returns:
- an event that is raised when a portion of raw stream compressed
-
setCompressionProgressed
public final void setCompressionProgressed(Event<ProgressEventArgs> value)
Sets an event that is raised when a portion of raw stream compressed.
archive.getEntries().get(0).setCompressionProgressed(new Event<ProgressEventArgs>() { public void invoke(Object sender, ProgressEventArgs progressEventArgs) { int percent = (int) ((100 * (long) progressEventArgs.getProceededBytes()) / entrySourceFile.length()); } });Event sender is an
XarFileEntryinstance.- Parameters:
value- an event that is raised when a portion of raw stream compressed
-
open
public final InputStream open()
Opens the entry for extraction and provides a stream with entry content.
Usage:try (FileOutputStream fileStream = new FileOutputStream("data.bin")) { try (InputStream decompressed = entry.open()) { byte[] buffer = new byte[8192]; int bytesRead; while (0 < (bytesRead = decompressed.read(buffer, 0, buffer.length))) { fileStream.write(buffer, 0, bytesRead); } } } catch (IOException ex) { }Read from the stream to get the original content of the file. See examples section.
- Returns:
- the stream that represents the contents of the entry
-
extract
public final File extract(String path)
Extracts the entry to the filesystem by the path provided.
try (XarArchive archive = new XarArchive("archive.xar")) { ((XarFileEntry)archive.getEntries().get(0)).extract("data.bin"); }- Specified by:
extractin interfaceIArchiveFileEntry- Parameters:
path- the path to destination file. If the file already exists, it will be overwritten- Returns:
- the file info of the extracted 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.InvalidDataException- The archive is corrupted.
-
extract
public final void extract(OutputStream destination)
Extracts the entry to the stream provided.
Extract an entry of wim archive.
try (FileOutputStream output = new FileOutputStream("file")){ try (XarArchive archive = new XarArchive("archive.xar")) { ((XarFileEntry)archive.getEntries().get(0)).extract(output); } } catch (IOException ex) { }- Specified by:
extractin interfaceIArchiveFileEntry- Parameters:
destination- destination stream. Must be writable- Throws:
com.aspose.ms.System.ArgumentException-destinationdoes not support writing.com.aspose.ms.System.IO.InvalidDataException- The archive is corrupted.
-
-