FileDocCategorySizeDatePackage
Filter.javaAPI DocExample1308Mon Apr 30 12:17:54 BST 2001None

Filter

public class Filter extends Object
Filter - template line-mode filter.
author
Ian F. Darwin, ian@darwinsys.com
version
$Id: Filter.java,v 1.3 2001/04/30 15:17:54 ian Exp $

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] av)
This simple main program looks after filenames and opening files and such like for you.

        Filter o = new Filter();
        if (av.length == 0) {
            o.process("standard input", new LineNumberReader(
				new InputStreamReader(System.in)));
		} else {
			for (int i=0; i<av.length; i++)
				try {
					o.process(av[i],
						new LineNumberReader(new FileReader(av[i])));
				} catch (FileNotFoundException e) {
					System.err.println(e);
				}
        }
    
protected voidprocess(java.lang.String fileName, java.io.LineNumberReader is)
Process one file

        try {
            String inputLine;

            while ((inputLine = is.readLine()) != null) {
				// This template Null Filter copies to stdout.
				// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
				// Typically this is all you need to change.
				// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
				System.out.println(inputLine);
            }
            is.close();
        } catch (IOException e) {
            System.out.println("IOException: " + e);
        }