FileDocCategorySizeDatePackage
Indent.javaAPI DocExample1152Sat Nov 25 12:56:14 GMT 2000None

Indent

public class Indent extends Object
Indent - prepend leading spaces
author
Ian F. Darwin, ian@darwinsys.com
version
$Id: Indent.java,v 1.2 2000/11/25 17:56:15 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);
        }