PregoZip Using Zip Routines in Java - by Markus Wilthaner - 4ADV 2002/2003 - Release: 2002-10-11

Synopsis

Requirements

Executables

Sources

Documentation

Synopsis:

A console-based application, written in Java. The user can enter a source directory, a target archive and an optional source archive. The program creates the target archive and copies the files from the directory into the archive. If the user specified a source archive, the files are only added if they are not in the source archiv yet or if the file in the source archive is older. The user should also be able to specifiy an unlimited amount of Include and Exclude filters (e.g. *.doc).

Command-line paramenters:
PregoZip <Directory> <Target archive> [Source archive] [-i <IncludeFilter1> <IncludeFilter2> ...] [-e <ExcludeFilter1> <ExcludeFilter2>


Homework Requirements (in German):

Datum: 2002-09-13
Ziel: 2002-10-11

Konsolenprogramm in Java, basierend auf Zip - Beispiel (siehe Dokumentation Seite 10). Dem Programm wird ein Quellverzeichnis, ein Zielarchiv und optional ein Quellarchiv übergeben.

Das Zielarchiv wird angelegt. Dann durchläuft das Programm das angegebene Directory und dessen Subdirectories und archiviert die Dateien in das Archiv.

Falls der User ein Quellarchiv angibt, wird vor dem Hinzufügen der Dateien in das neue Archiv geprüft, ob die Datei schon im alten Archiv existiert. Falls die Datei im alten Archiv nicht existiert oder älter ist, soll die Datei ins neue Archiv übernommen werden. Ansonsten kann die Datei ausgelassen werden.

Umfang:

  • Programmcode

  • Abgespeckte UML Darstellung aller Klassen inkl. Vererbungshierarchie (a la BlueJava Entwicklungsumgebung)

Die Kommandozeile muss über folgende Features verfügen:

Kommandozeile: Programmname <Quellverzeichnis> <Zielarchiv> [Quellarchiv] [-i <filter1><filter2>...] [-e <filter1><filter2>...]

Quellverzeichnis

Ein Verzeichnis, soll durchlaufen werden

Zielarchiv

Das neue Archiv

Quellarchiv

Das alte Archiv

-i

Alle Dateien, die entweder filter1 oder filter2 ... entsprechen, sollen ins Archiv aufgenommen werden

-e

Alle Dateien, die entweder filter1 oder filter2 ... entsprechen, sollen nicht ins Archiv aufgenommen werden

Die Anzahl der Filter soll, soweit möglich, nicht limitiert sein. Der Benutzer kann sowohl –e als auch –i verwenden, er kann aber auch beide Optionen weglassen.

Das genaue Format der Kommandozeile ist nicht vorgeschrieben und kann beliebig variiert werden!


Executables

Executable:

pregozip.jar

Download the executable and start it with the command java -jar pregozip.jar <command line parameters>.
This program was developed on and requires the JDK 1.4.0.1. The JDK is available at http://java.sun.com.


Sourcefiles:

The program uses 5 classes. Click on the classes to download the sourcecode:

PregoZip.java

The main class - offers a command-line interface to the classes and controls them

Directory.java

Class used for directory processing. Supports Filters and recursive sub-directory indexing.

FileFilter.java

Simple filtering methods for filenames.

ZipReader.java

Extends java.util.zip.ZipFile by fileExists, a function that checks if the file already exists in the archive

ZipWriter.java

An extension to File, this class offers functions for adding files to a zip archive.


Documentation

This diagram shows how the classes use each other:

The sourcefiles document each function, it's purpose, parameters and return values. The sourcefiles also including rudimentary inline-comments.

Java Documentation

All public functions, the classes and the inheritance structure are documented in the javadoc of PregoZip.

 

(c) 2002 by Markus Wilthaner - E-Mail: contact@wilth.net
Disclaimer: This is provided "as-is" without any warranty. You can use the provided information at your own risk for academic, private, non-governmental and non-commercial use. Copyright laws require you to correctly quote the author when reusing his work. All rights reserved.