An Instrumented JavaCode

 

/*

     This code reads from an existing file inFile.txt in the folder MyFolder on the C drive and writes 

     the input to a second file outFile.txt in that folder.

     The Pablo instrumentation will capture the instantiation of the input and output steams and the read, 

     write, flush and close operations.

*/

import java.io.FileNotFoundException;

import java.io.IOException;

import PabloIOTracing.*;    // Import the Pablo Java tracing package

 

class Test

{

public static void main( String args[] ) throws FileNotFoundException,IOException

{

// Instantiate a PabloTracer object specifying the trace file name and the

// processor number or 0.

 

PabloTracer pt = new PabloTracer( "C:/MyTraceFolder/MyTraceFile", 0 );

 

// use PabloFileInputStream and PabloFileOutputStream for the classes instead of

// FileInputStream and FileOutputStream.

 

PabloFileInputStream pfis = new PabloFileInputStream("C:/MyFolder/inFile.txt");

PabloFileOutputStream pfos = new PabloFileOutputStream("C:/MyFolder/outFile.txt");

byte[] buff = new byte[256];

int len;

while( (len = pfis.read(buff)) > 0 )

{

     pfos.write(buff,0,len);

}

pfos.flush();

pfos.close();

pfis.close();

pt.end(); // Terminate tracing

}

}