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();
}

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 ( ) ; }
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 .
