FileDocCategorySizeDatePackage
Undent.javaAPI DocExample1318Sun Feb 22 15:45:02 GMT 2004None

Undent

public class Undent extends Object
Undent - remove leading spaces
author
Ian F. Darwin, http://www.darwinsys.com/
version
$Id: Undent.java,v 1.5 2004/02/22 21:45:02 ian Exp $

Fields Summary
protected int
nSpaces
the maximum number of spaces to remove.
Constructors Summary
Undent(int n)

		nSpaces = n;
	
Methods Summary
public static voidmain(java.lang.String[] av)

        Undent c = new Undent(5);
        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) {
				int toRemove = 0;
				for (int i=0; i<nSpaces && i < inputLine.length() && 
				Character.isWhitespace(inputLine.charAt(i)); i++)
						++toRemove;
                System.out.println(inputLine.substring(toRemove));
            }
			//-
            is.close();
        } catch (IOException e) {
            System.out.println("IOException: " + e);
        }