question: static void generateCharacterClass ( String theTemplateFileName , String theOutputFileName ) throws FileNotFoundException , IOException { BufferedReader in = new BufferedReader ( new FileReader ( theTemplateFileName ) ) ; PrintWriter out = new PrintWriter ( new BufferedWriter ( new FileWriter ( theOutputFileName ) ) ) ; out . println ( commentStart + " This file was generated AUTOMATICALLY from a template file " + new java . util . Date ( ) + commentEnd ) ; int marklen = commandMarker . length ( ) ; LOOP : while ( true ) { try { String line = in . readLine ( ) ; if ( line == null ) break LOOP ; int pos = 0 ; int depth = 0 ; while ( ( pos = line . indexOf ( commandMarker , pos ) ) >= 0 ) { int newpos = pos + marklen ; char ch = 'x' ; SCAN : while ( newpos < line . length ( ) && ( Character . isJavaIdentifierStart ( ch = line . charAt ( newpos ) ) || ch == '(' || ( ch == ')' && depth > 0 ) ) ) { ++ newpos ; if ( ch == '(' ) { ++ depth ; } else if ( ch == ')' ) { -- depth ; if ( depth == 0 ) break SCAN ; } } String replacement = replaceCommand ( line . substring ( pos + marklen , newpos ) ) ; line = line . substring ( 0 , pos ) + replacement + line . substring ( newpos ) ; pos += replacement . length ( ) ; } out . println ( line ) ; } catch ( IOException e ) { break LOOP ; } } in . close ( ) ; out . close ( ) ; }
target:  Once the compressed tables have been computed, this method reads in a template file for the source code to be generated and writes out the final source code by acting as a sort of specialized macro processor. The first output line is a comment saying that the file was automatically generated; it includes a timestamp.  All other output is generated by reading a line from the template file, performing macro replacements, and then writing the resulting line or lines of code to the output file. This method handles the I/O, the timestamp comment, and the locating of macro calls within each input line.  The method replaceCommand is called to generate replacement text for each macro call. Macro calls to be replaced are indicated in the template file by occurrences of the commandMarker "$$".  The rest of the call may consist of Java letters (including the underscore "_") and also of balanced parentheses.