## Determining method execution sequence

You can determine the sequence of method execution by writing code that generates a file containing a line for every method that you want to track.

To create an output file containing a sequence of method execution, include initialization code in the ReportDesign.initialize method and finalization code in the ReportDesign.afterFactory method. In each method that you want to track, add code to write a line of text to the output file. It is easier to write the code in JavaScript than Java, but it is possible to write analogous code in Java.

The following sections show you how to use JavaScript to determine method execution sequence.

### Providing the ReportDesign.initialize code

The following code in the ReportDesign.initialize method creates a file on your hard drive and adds one line to the file.

    importPackage( Packages.java.io );
    fos = new java.io.FileOutputStream( "c:\\logFile.txt" );
    printWriter = new java.io.PrintWriter( fos );
    printWriter.println( "ReportDesign.initialize" );

The preceding code does the following tasks:

- Imports the Java package, java.io
- Creates a file output stream for the file you want to create
- Creates a PrintWriter object that every method can use to track method execution sequence