Print input arguments to a file

 

+

Search Tips   |   Advanced Search

 

The PrintArgs class prints its input arguments to the file C:\arguments.out. This class could be used, for example, to print a response returned by the server.

package test;

import com.ibm.rational.test.lt.kernel.services.ITestExecutionServices;

import java.io.*;

/**
 * The PrintArgs class prints its input arguments to the file
 * C:\arguments.out.  This example could be used to print a response
 * returned by the server.
 */

/**
 * @author IBM Custom Code Samples
 */

public class PrintArgs implements
        com.ibm.rational.test.lt.kernel.custom.ICustomCode2 
{

    /**
     * Create using the no-arg constructor.
     */
    public PrintArgs() 
    {
    }

    public String exec(ITestExecutionServices tes, String[] args) 
    {
        try 
        {
            FileWriter outFile = new FileWriter("C:\\arguments.out");

            for (int i = 0; i < args.length; i++)
                outFile.write("Argument " + i + " is: " + args[i] + "\n");

            outFile.close();

        } 
        catch (IOException e) 
        {
            tes.getTestLogManager().reportMessage("Unable to write to C:\\arguments.out");
        }
        return null;
    }
}