Skip to content

Instantly share code, notes, and snippets.

@linghuiluo
Last active November 16, 2018 12:53
Show Gist options
  • Save linghuiluo/27809528ad273945b0110c1af8cb1d12 to your computer and use it in GitHub Desktop.
Save linghuiluo/27809528ad273945b0110c1af8cb1d12 to your computer and use it in GitHub Desktop.

Back to my page

Print a SootClass/Body

Output in console

    soot.SootClass c = // your SootClass
    PrintWriter writer = new PrintWriter(System.out); 
    soot.Printer.v().printTo(c, writer);
    writer.flush();
    writer.close();
   soot.Body c = // your method Body
   PrintWriter writer = new PrintWriter(System.out);
   soot.Printer.v().printTo(c, writer);
   writer.flush();
   writer.close();

Output a .jimple file

   soot.SootClass c = // your SootClass
   File file = new File(c.getName() + ".jimple");
   PrintWriter writer;
   try {
     writer = new PrintWriter(file);
     soot.Printer.v().printTo(c, writer);
     writer.flush();
     writer.close();
   } catch (FileNotFoundException e) {
     e.printStackTrace();
   }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment