FileDocCategorySizeDatePackage
Filter.javaAPI DocExample1316Sun Feb 08 21:34:06 GMT 2004None

Filter

public class Filter extends Object
Filter - template line-mode filter.
author
Ian F. Darwin, http://www.darwinsys.com/
version
$Id: Filter.java,v 1.4 2004/02/09 03:34:05 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);
        }