FileDocCategorySizeDatePackage
CheckFiles.javaAPI DocExample1499Sat Nov 25 12:54:54 GMT 2000None

CheckFiles

public class CheckFiles extends Object
Get a list of files, and check if any files are missing.
author
Ian F. Darwin, ian@darwinsys.com
version
$Id: CheckFiles.java,v 1.2 2000/11/25 17:54:54 ian Exp $

Fields Summary
public String
FILENAME
protected ArrayList
listFromFile
protected ArrayList
listFromDir
Constructors Summary
Methods Summary
protected voidgetListFromDirectory()
Get list of names from the directory

		listFromDir = new ArrayList();
		String[] l = new java.io.File(".").list();
		for (int i=0; i<l.length; i++)
			listFromDir.add(l[i]);
	
protected voidgetListFromFile()


	   
		listFromFile = new ArrayList();
		BufferedReader is;
		try {
			is = new BufferedReader(new FileReader(FILENAME));
			String line;
			while ((line = is.readLine()) != null)
				listFromFile.add(line);
		} catch (FileNotFoundException e) {
			System.err.println("Can't open file list file.");
			return;
		} catch (IOException e) {
			System.err.println("Error reading file list");
			return;
		}
	
public static voidmain(java.lang.String[] argv)

		CheckFiles cf = new CheckFiles();
		System.out.println("CheckFiles starting.");
		cf.getListFromFile();
		cf.getListFromDirectory();
		cf.reportMissingFiles();
		System.out.println("CheckFiles done.");
	
protected voidreportMissingFiles()

		for (int i=0; i<listFromFile.size(); i++)
			if (!listFromDir.contains(listFromFile.get(i)))
				System.err.println("File " + listFromFile.get(i) + " missing.");