public void writeFile(String dir){
  String filePath=dir + File.separator + mSootClass.toString();
  PrintWriter writer;
  try {
    writer=new PrintWriter(filePath + "_steps.jimple");
  }
 catch (  Exception ex) {
    logger.warn("Cannot open file {} ",filePath);
    return;
  }
  writer.printf("class %s { \n",mSootClass.toString());
  writer.println("");
  logger.info("fields ");
  for (  SootField field : mSootClass.getFields()) {
    logger.info("field {} ",field);
    writer.printf("\t%s %s \n",Modifier.toString(field.getModifiers()),field);
  }
  logger.info("methods ");
  writer.println("");
  for (  SootMethod method : mSootClass.getMethods()) {
    Body body=method.getActiveBody();
    logger.info("====== method {} ======== ",method);
    writer.printf("\t%s %s { \n",Modifier.toString(method.getModifiers()),method);
    for (    Local local : body.getLocals()) {
      logger.info("{}",local);
      writer.printf("\t\t%s %s \n",local.getType(),local);
    }
    writer.println("");
    Chain<Unit> units=body.getUnits();
    for (    Unit unit : units) {
      String unitString;
      try {
        unitString=unit.toString();
      }
 catch (      Exception ex) {
        unitString="***Invalid Statement ";
      }
      writer.printf("\t\t%s \n",unitString);
      logger.info("{} ",unitString);
    }
    writer.printf("\t} \n");
    logger.info("");
  }
  writer.printf("} \n");
  writer.flush();
}

public void writeFile ( String dir ) { String filePath = dir + File . separator + mSootClass . toString ( ) ; PrintWriter writer ; try { writer = new PrintWriter ( filePath + "_steps.jimple" ) ; } catch ( Exception ex ) { logger . warn ( "Cannot open file {} " , filePath ) ; return ; } writer . printf ( "class %s { \n" , mSootClass . toString ( ) ) ; writer . println ( "" ) ; logger . info ( "fields " ) ; for ( SootField field : mSootClass . getFields ( ) ) { logger . info ( "field {} " , field ) ; writer . printf ( "\t%s %s \n" , Modifier . toString ( field . getModifiers ( ) ) , field ) ; } logger . info ( "methods " ) ; writer . println ( "" ) ; for ( SootMethod method : mSootClass . getMethods ( ) ) { Body body = method . getActiveBody ( ) ; logger . info ( "====== method {} ======== " , method ) ; writer . printf ( "\t%s %s { \n" , Modifier . toString ( method . getModifiers ( ) ) , method ) ; for ( Local local : body . getLocals ( ) ) { logger . info ( "{}" , local ) ; writer . printf ( "\t\t%s %s \n" , local . getType ( ) , local ) ; } writer . println ( "" ) ; Chain < Unit > units = body . getUnits ( ) ; for ( Unit unit : units ) { String unitString ; try { unitString = unit . toString ( ) ; } catch ( Exception ex ) { unitString = "***Invalid Statement " ; } writer . printf ( "\t\t%s \n" , unitString ) ; logger . info ( "{} " , unitString ) ; } writer . printf ( "\t} \n" ) ; logger . info ( "" ) ; } writer . printf ( "} \n" ) ; writer . flush ( ) ; }
write to the file
