de.schlichtherle
Class NZip

java.lang.Object
  extended by de.schlichtherle.NZip
Direct Known Subclasses:
nzip

public class NZip
extends Object

A comprehensive command line utility which allows you to work with entries in all supported archive files using Unix like commands (cat, cp, rm, mkdir, rmdir, ls etc.).

Please note that TrueZIP is designed for optimum performance. However, this utility features some optional archive drivers which provide additional safety or otherwise unavailable features. Some of these drivers are not used in their default configuration - see DefaultArchiveDetector for more information. For example, the ZIP drivers used in this utility always check the CRC-32 values provided in the ZIP file. In addition, the SFX driver is used which allows you to browse .exe files if they happen to be SelF eXtracting archives (SFX). If they are not however, TrueZIP may spend some considerable amount of time searching for the Central Directory required to be present in ZIP (and hence SFX) files. As a conclusion, this utility should not serve as a performance benchmark.

This class is not thread safe.

Since:
TrueZIP 6.5
Version:
TrueZIP 6.7
Author:
Christian Schlichtherle

Nested Class Summary
protected static class de.schlichtherle.CommandLineUtility.ProgressMonitor
           
 class NZip.IllegalUsageException
           
 
Field Summary
protected  PrintStream err
          The print stream for error output.
protected  PrintStream out
          The print stream for standard output.
protected  de.schlichtherle.CommandLineUtility.ProgressMonitor progressMonitor
          The command line progress monitor.
 
Constructor Summary
NZip()
           
NZip(OutputStream out, OutputStream err, boolean autoFlush)
           
 
Method Summary
protected  DefaultArchiveDetector createDefaultArchiveDetector()
          May be overridden by subclasses to create the ArchiveDetector which shall be used as the default archive detector while a command is running.
protected  DefaultArchiveDetector createDefaultArchiveDetector(String charset)
          May be overridden by subclasses to create the ArchiveDetector which returns ArchiveDrivers which should use the specified charset if supported.
static void main(String[] args)
          Equivalent to System.exit(new NZip().run(args));.
 int run(String[] args)
          Runs this command line utility.
 boolean runWithException(String[] args)
          Runs this command line utility.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

out

protected final PrintStream out
The print stream for standard output.


err

protected final PrintStream err
The print stream for error output.


progressMonitor

protected final de.schlichtherle.CommandLineUtility.ProgressMonitor progressMonitor
The command line progress monitor.

Constructor Detail

NZip

public NZip()

NZip

public NZip(OutputStream out,
            OutputStream err,
            boolean autoFlush)
Method Detail

createDefaultArchiveDetector

protected DefaultArchiveDetector createDefaultArchiveDetector()
May be overridden by subclasses to create the ArchiveDetector which shall be used as the default archive detector while a command is running. The ArchiveDrivers returned by the archive detector should use their default charsets.

Note that the archive detector which is returned by the implementation in this class uses some archive drivers which may be pretty slow due to some extra compatibility tests which they perform on every archive.


createDefaultArchiveDetector

protected DefaultArchiveDetector createDefaultArchiveDetector(String charset)
May be overridden by subclasses to create the ArchiveDetector which returns ArchiveDrivers which should use the specified charset if supported. This is used by selected commands in this class.

Note that the archive detector which is returned by the implementation in this class uses some archive drivers which may be pretty slow due to some extra compatibility tests which they perform on every archive.


main

public static void main(String[] args)
Equivalent to System.exit(new NZip().run(args));.


runWithException

public boolean runWithException(String[] args)
                         throws NZip.IllegalUsageException,
                                IOException
Runs this command line utility. Throws an exception if an error occurs.

Parameters:
args - A non-empty array of Unix-like commands and optional parameters.
Returns:
false iff the command is a test which fails, true otherwise.
Throws:
NZip.IllegalUsageException - If args does not contain correct commands or parameters.
IOException - On any I/O related exception.

run

public final int run(String[] args)
Runs this command line utility. Prints a user readable error message to the error output stream which was provided to the constructor if an error occurs.

Parameters:
args - A non-empty array of Unix-like commands and optional parameters.
Returns:
1 iff the command fails, 0 otherwise.