FileDocCategorySizeDatePackage
Indent.javaAPI DocExample1160Sun Feb 08 21:34:04 GMT 2004None

Indent

public class Indent extends Object
Indent - prepend leading spaces
author
Ian F. Darwin, http://www.darwinsys.com/
version
$Id: Indent.java,v 1.3 2004/02/09 03:34:03 ian Exp $

Fields Summary
static int
nSpaces
the default number of spaces.
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] av)


         
        Indent c = new Indent();
        switch(av.length) {
            case 0: c.process(new BufferedReader(
                        new InputStreamReader(System.in))); break;
            default:
		for (int i=0; i<av.length; i++)
			try {
				c.process(new BufferedReader(new FileReader(av[i])));
			} catch (FileNotFoundException e) {
				System.err.println(e);
			}
        }
    
public voidprocess(java.io.BufferedReader is)
print one file, given an open BufferedReader

        try {
            String inputLine;

			//+
            while ((inputLine = is.readLine()) != null) {
				for (int i=0; i<nSpaces; i++) System.out.print(' ");
                System.out.println(inputLine);
            }
			//-
            is.close();
        } catch (IOException e) {
            System.out.println("IOException: " + e);
        }