[Demonstration 1]

[Buggy Method]
private void dumpStatsToFile() throws IOException {
    StringBuilder sb = new StringBuilder();
    sb.append("\nSTATS\n");
    List<Map<Integer, Integer>> list = Arrays.asList(getCounter, insertCounter, removeCounter);
    for (int i = 0; i < 3; i++) {
        Map<Integer, Integer> m = list.get(i);
        switch(i) {
            case 0:
                sb.append("\tGET\n");
                break;
            case 1:
                sb.append("\tINSERT\n");
                break;
            case 2:
                sb.append("\tREMOVE\n");
        }
        for (int index : m.keySet()) {
            sb.append("\t\t");
            sb.append(index);
            sb.append(": ");
            sb.append(m.get(index));
            sb.append('\n');
        }
    }
    FileOutputStream fos = new FileOutputStream(filename);
    fos.write(sb.toString().getBytes());
    fos.close();
}

[Buggy Hunk]
FileOutputStream fos = new FileOutputStream(filename);

[Patch]
FileOutputStream fos = new FileOutputStream(filename, true);

[Demonstration 2]

[Buggy Method]
public static void build_constructor() {
    if (put_constructor) {
        buffer.append("public ").append(global_object.class_type).append("()\n\t{\n\t\t\n\t}");
    }
}

[Buggy Hunk]
buffer.append("public ").append(global_object.class_type).append("()\n\t{\n\t\t\n\t}");

[Patch]
buffer.append("public ").append(global_object.name).append("()\n\t{\n\t\t\n\t}");

[Demonstration 3]

[Buggy Method]
private Uri createMilestoneListToCSV(List<MilestonesDao> milestonesList) {
    String header = "\"Date\",\"Milestone\"\n";
    StringBuilder stringBuilder = new StringBuilder();
    for (MilestonesDao milestoneItem : milestonesList) {
        stringBuilder.append("\"" + milestoneItem.getDate() + "\",\"" + milestoneItem.getTitle() + "\",\"");
    }
    String combinedString = header + stringBuilder.toString();
    Log.d(TAG, "combined " + combinedString);
    File file = null;
    File root = Environment.getExternalStorageDirectory();
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy_MM_dd");
    if (root.canWrite()) {
        File dir = new File(root.getAbsolutePath() + "/MileStoneLogs");
        dir.mkdirs();
        file = new File(dir, simpleDateFormat.format(getStartTime()) + " to " + simpleDateFormat.format(getEndTime()) + "_milestones" + ".csv");
        FileOutputStream out = null;
        try {
            out = new FileOutputStream(file);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        try {
            out.write(combinedString.getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return Uri.fromFile(file);
}

[Buggy Hunk]
+ milestoneItem.getTitle() + "\",\"");

[Patch]
+ milestoneItem.getTitle() + "\"\n");