src/main/java/org/plumelib/bcelutil/BcelUtil.java
public static void dump(JavaClass jc, File dumpDir) {

    try {
      dumpDir.mkdir();
      File path = new File(dumpDir, jc.getClassName() + ".bcel");
      PrintStream p = new PrintStream(path);

      // Print the class, superclass, and interfaces
      p.printf("class %s extends %s%n", jc.getClassName(), jc.getSuperclassName());
      String[] inames = jc.getInterfaceNames();
      boolean first = true;
      if ((inames != null) && (inames.length > 0)) {
        p.printf("   implements ");
        for (String iname : inames) {
          if (!first) p.printf(", ");
          p.printf("%s", iname);
          first = false;
        }
        p.printf("%n");
      }

      // Print each field
      p.printf("%nFields%n");
      for (Field f : jc.getFields()) {
        p.printf("  %s%n", f);
      }

      // Print the signature of each method
      p.printf("%nMethods%n");
      for (Method m : jc.getMethods()) {
        p.printf("  %s%n", m);
      }

      for (Method m : jc.getMethods()) {
        Code code = m.getCode();
        if (code != null) {
          p.printf("%nMethod %s%n", m);
          p.printf("  %s%n", code.toString().replace("\n", "\n  "));
        }
      }

      // Print the details of the constant pool.
      p.printf("Constant Pool:%n");
      ConstantPool cp = jc.getConstantPool();
      Constant[] constants = cp.getConstantPool();
      for (int ii = 0; ii < constants.length; ii++) {
        p.printf("  %d %s%n", ii, constants[ii]);
      }

      p.close();

    } catch (Exception e) {
      throw new Error(
          "Unexpected error dumping JavaClass: " + jc.getClassName() + " to " + dumpDir.getName(),
          e);
    }
  }
public static void dump(JavaClass jc, File dumpDir) {

    try {
      dumpDir.mkdir();
      File path = new File(dumpDir, jc.getClassName() + ".bcel");
      PrintStream p = new PrintStream(path);

      // Print the class, superclass, and interfaces
      p.printf("class %s extends %s%n", jc.getClassName(), jc.getSuperclassName());
      String[] inames = jc.getInterfaceNames();
      boolean first = true;
      if ((inames != null) && (inames.length > 0)) {
        p.printf("   implements ");
        for (String iname : inames) {
          if (!first) p.printf(", ");
          p.printf("%s", iname);
          first = false;
        }
        p.printf("%n");
      }

      // Print each field
      p.printf("%nFields%n");
      for (Field f : jc.getFields()) {
        p.printf("  %s%n", f);
      }

      // Print the signature of each method
      p.printf("%nMethods%n");
      for (Method m : jc.getMethods()) {
        p.printf("  %s%n", m);
      }

      for (Method m : jc.getMethods()) {
        Code code = m.getCode();
        if (code != null) {
          p.printf("%nMethod %s%n", m);
          p.printf("  %s%n", code.toString().replace("\n", "\n  "));
        }
      }

      // Print the details of the constant pool.
      p.printf("Constant Pool:%n");
      ConstantPool cp = jc.getConstantPool();
      Constant[] constants = cp.getConstantPool();
      for (int ii = 0; ii < constants.length; ii++) {
        p.printf("  %d %s%n", ii, constants[ii]);
      }

      p.close();

    } catch (Exception e) {
      throw new Error(
          "Unexpected error dumping JavaClass: " + jc.getClassName() + " to " + dumpDir.getName(),
          e);
    }
  }
Dumps the contents of the specified class to the specified directory. The file is named
dumpDir/[class].bcel. It contains a synopsis of the fields and methods followed by the JVM code
for each method.

@param jc JavaClass to dump
@param dumpDir directory in which to write the file