From: "Erik Hanson" 
To: 
Subject: ConvertComments changes
Date: Mon, 23 Nov 1998 14:00:11 -0500

George:

I found your ConvertComments program right after I tried to javadoc the Acme
classes. I wanted to convert all the files so I modified your program to
recursively process directories. So now if I call "java ConvertComments
Acme", all the .java files in the "Acme" directory will be converted.

I changed main() and added a class called addToFileList(). I thought I'd
send you my changes in case you are interested. The code isn't very good for
two reasons: first, I only spent a few minutes on it, and second, I haven't
done much with java.io before.

Also, I only tested it with passing in a directory name, not a file name. I
only needed the program to work once.


Thanks for writing this program, and thanks for putting the source out
there!
Erik

- - - - -


    /** Read and write Java source code files.
     * With no arguments, reads from System.in, writes to System.out.
     * If given file names overwrites files in place.
     * Pass a -d to start debugging output to System.err.
     * Usage: java Acme.ConvertComments [ -d | File.java ...]
     */
    public static void main(String [] args) throws IOException
    {
        ConvertComments c = new ConvertComments();
        Vector files = new Vector();

        if(args.length == 0 || args.length == 1 && args[0].equals("-d"))
        {
            c.debug = (args.length == 1);
            c.convert(System.in, System.out);
        }
        else
        {
   	    c.debug = addToFileList( args, null, files );
  	}


  int size = files.size();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  System.out.println( "Files remaining:" );
  for ( int j = 0; j < size; j++ )
  {
            out.reset();
            System.out.print( size - j + " " );
            FileInputStream in = new
leInputStream( (File)files.elementAt( j ) );
            c.convert(in, out);
            in.close();
            new
FileOutputStream( (File)files.elementAt( j ) ).write(out.toByteArray());
  }

    }


 /**
  * Add the array of file names to the vector of file names. Recurses
directories.
  * @return true if a debug flag was found.
  */
 public static boolean addToFileList( String inArgs[], File inDirectory,
Vector outFileList )
 {
  File    file;
  boolean debug = false;

  for ( int i = 0; i < inArgs.length; i++ )
  {
            if( inArgs[i].equals( "-d" ) )


                System.out.println("Debugging enabled.");
                debug = true;
                continue;
            }

   if ( inDirectory != null )
   {
    String path = inDirectory.getAbsolutePath();
    if ( ! path.endsWith( File.separator ) )
    {
     file = new File( path + File.separatorChar + inArgs[i] );
    }
    else
    {
     file = new File( path  + inArgs[i] );
    }
   }
   else
   {
    file = new File( inArgs[i] );
   }

   if ( file.isDirectory() )
   {
    addToFileList( file.list(), file, outFileList );
   }
   else
   {
    if ( file.getName().endsWith( ".java" ) )
    {
     outFileList.addElement( file );
    }
   }
  }

  return debug;
 }

    Source: geocities.com/george_ruban