[Demonstration 1]

[Buggy Method]
@BeforeClass
public static void setUpClass() {
    lineSeparator = System.lineSeparator();
    originalStdOut = System.out;
    originalStdErr = System.err;
    PrintStream out = new PrintStream(standardOut);
    System.setOut(out);
    System.setErr(out);
}

[Buggy Hunk]
PrintStream out = new PrintStream(standardOut);

[Patch]
PrintStream out = new PrintStream(standardOutAndErr);

[Demonstration 2]

[Buggy Method]
public List<SelectItem> getWhodDictinoriesSI() {
    if (whodDictinoriesSI == null) {
        List<SelectItem> selectItems = new ArrayList<SelectItem>();
        List<SelectItem> selectItemsToSet = new ArrayList<SelectItem>();
        selectItems = ADFUtils.selectItemsForIteratorbyPageDef(WHOD_SEARCH_PAGE_DEF, "WhodDictionariesListVO1Iterator", "ShortValue", "LongValue");
        Object mode = ADFContext.getCurrent().getPageFlowScope().get("setMode");
        if (mode != null && mode.toString().equals("update")) {
            for (SelectItem selectItem : selectItems) {
                if (selectItem.getValue().toString().equals(CSMQBean.WHOD_FILTER_DICTIONARY))
                    selectItemsToSet.add(selectItem);
            }
            whodDictinoriesSI = selectItemsToSet;
        } else {
            whodDictinoriesSI = selectItems;
        }
    }
    return whodDictinoriesSI;
}

[Buggy Hunk]
if (mode != null && mode.toString().equals("update")) {

[Patch]
if (mode != null && (mode.toString().equals("update") || mode.toString().equals("copy"))) {

[Demonstration 3]

[Buggy Method]
public static void main(String[] args) {
    String infile = "";
    String outfile = "";
    String mode = "";
    String lang = "";
    if (args.length == 4 && (args[1].equalsIgnoreCase("-READ") || args[1].equalsIgnoreCase("-OCR") || args[1].equalsIgnoreCase("-AUTO"))) {
        lang = args[0];
        mode = args[1];
        infile = args[2];
        outfile = args[3];
        System.out.println("lang: " + lang);
        System.out.println("mode: " + mode);
        System.out.println("infile: " + infile);
        System.out.println("outfile: " + outfile);
        if (mode.equalsIgnoreCase("-READ")) {
            System.out.println(getText(infile, outfile));
        } else if (mode.equalsIgnoreCase("-OCR")) {
            System.out.println(tryOCR(lang, infile, outfile));
        } else if (mode.equalsIgnoreCase("-AUTO")) {
            String readresult = "";
            try {
                readresult = getText(infile, outfile);
            } catch (Exception e) {
                System.err.println(e.getMessage());
            }
            if (readresult.length() > 20) {
                // did read successfully
            } else {
                readresult = tryOCR(lang, infile, outfile);
            }
        }
    } else if (args.length == 5 && args[0].equalsIgnoreCase("-OVERLAY")) {
        mode = args[0];
        infile = args[1];
        outfile = args[2];
        String text = args[3];
        String color = args[4];
        System.out.println("mode: " + mode);
        System.out.println("infile: " + infile);
        System.out.println("outfile: " + outfile);
        System.out.println("text: " + text);
        Color ocolor = Color.WHITE;
        if (color.equalsIgnoreCase("Color.WHITE")) {
            ocolor = Color.WHITE;
        } else {
            ocolor = Color.BLACK;
        }
        System.out.println("color: " + ocolor.toString());
        Boolean ok = overlay(infile, outfile, text, ocolor);
    } else {
        System.out.println("There are different modes how to use this Program:");
        System.out.println("1. OCR mode:  has 4 parameters: lang (-DEU/-ENG), mode (-OCR/-READ/-AUTO), infile (PDF/BMP/TIF/PNG) and outfile (TXT)");
        System.out.println("2. WhiteOnWhite Overlay mode: has 5 parameters: mode (-OVERLAY), infile (PDF), outfile (PDF), text (String) and color (Color.WHITE/Color.BLACK)");
    }
}

[Buggy Hunk]
Boolean ok = overlay(infile, outfile, text, ocolor);

[Patch]
Boolean ok = overlayPDF(infile, outfile, text, ocolor);