net.sf.jomic.tools
Class FileArchive

java.lang.Object
  extended by net.sf.jomic.tools.FileArchive

public class FileArchive
extends java.lang.Object

An archive containing files. Currently supported formats are ZIP and RAR.

For hints and implementation details on various archive formats, see for example Marco Schmidt's list of archive file formats and archivers .

Author:
Thomas Aglassinger

Constructor Summary
FileArchive(java.io.File newFile)
           
 
Method Summary
 void extract(java.io.File targetDir, java.lang.String[] fileNamesToExtract)
           
 void extract(java.io.File targetDir, java.lang.String[] fileNamesToExtract, ProgressFrame progressFrame, long progressIncrement)
          Extract to targetDir all files in fileNamesToExtract.
 java.lang.String getBaseName()
          Get the plain name of the archive file, without directory and suffix.
 java.lang.String getFileType()
          Get the file type of the archive.
 java.lang.String[] list()
           
 void removeExtracted(java.io.File targetDir)
          Attempt to remove all files that could have been extracted from the archive to targetDir .
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileArchive

public FileArchive(java.io.File newFile)
            throws java.io.IOException
Throws:
java.io.IOException
Method Detail

getBaseName

public java.lang.String getBaseName()
Get the plain name of the archive file, without directory and suffix. Example: "/Users/me/Comics/blah.cbz" yields "blah".


getFileType

public java.lang.String getFileType()
Get the file type of the archive.

Returns:
one of: FileTools.FORMAT_ZIP, FileTools.FORMAT_RAR, FileTools.FORMAT_PDF

extract

public void extract(java.io.File targetDir,
                    java.lang.String[] fileNamesToExtract,
                    ProgressFrame progressFrame,
                    long progressIncrement)
             throws java.io.IOException
Extract to targetDir all files in fileNamesToExtract. If progressFrame is not null, advance its progress bar by progressIncrement for every file that is extracted.

Throws:
java.io.IOException

extract

public void extract(java.io.File targetDir,
                    java.lang.String[] fileNamesToExtract)
             throws java.io.IOException
Throws:
java.io.IOException

list

public java.lang.String[] list()
                        throws java.io.IOException
Throws:
java.io.IOException

removeExtracted

public void removeExtracted(java.io.File targetDir)
                     throws java.io.IOException
Attempt to remove all files that could have been extracted from the archive to targetDir . If a file cannot be removed, log a warning and continue.

Throws:
java.io.IOException