[Demonstration 1]

[Buggy Method]
public String nextPermutation(String str) {
    StringBuilder sb = new StringBuilder(str);
    int x1, x2;
    x1 = str.length() - 1;
    while (x1 > 0 && str.charAt(x1 - 1) > str.charAt(x1)) {
        x1--;
    }
    x1 = x1 - 1;
    // 已经是最后一个permutation
    if (x1 < 0)
        return null;
    x2 = str.length() - 1;
    while (str.charAt(x2) < str.charAt(x1)) {
        x2--;
    }
    char t;
    t = sb.charAt(x1);
    sb.setCharAt(x1, str.charAt(x2));
    sb.setCharAt(x2, t);
    StringBuilder t_sb = new StringBuilder(sb.substring(x1 + 1, str.length()));
    t_sb.reverse();
    sb.replace(x1 + 1, sb.length(), t_sb.toString());
    return sb.toString();
}

[Buggy Hunk]
while(str.charAt(x2) < str.charAt(x1)) {

[Patch]
while(str.charAt(x2) <= str.charAt(x1)) {

[Demonstration 2]

[Buggy Method]
public Span[] sentPosDetect(String s) {
    List<Span> sentences = new ArrayList<Span>();
    int start = 0;
    for (int i = 0; i < s.length(); i++) {
        char c = s.charAt(i);
        if (c == '\n' || c == '\r') {
            if (start - i > 0) {
                Span span = new Span(start, i).trim(s);
                if (span.length() > 0) {
                    sentences.add(span);
                }
                start = i + 1;
            }
        }
    }
    if (s.length() - start > 0) {
        Span span = new Span(start, s.length()).trim(s);
        if (span.length() > 0) {
            sentences.add(span);
        }
    }
    return sentences.toArray(new Span[sentences.size()]);
}

[Buggy Hunk]
if (start - i > 0) {

[Patch]
if (i - start > 0) {

[Demonstration 3]

[Buggy Method]
public static Map<String, String> importDictionary(String filename) {
    HashMap<String, String> map = new HashMap<String, String>();
    try {
        BufferedReader in = new BufferedReader(new FileReader(filename));
        String line;
        while ((line = in.readLine()) != null) {
            if (line.isEmpty() || line.charAt(0) == '#')
                continue;
            StringTokenizer st = new StringTokenizer(line, "|");
            String foreign = st.nextToken().trim().toLowerCase();
            String english = st.nextToken().trim();
            map.put(foreign, english);
        }
        return map;
    } catch (Exception e) {
        e.printStackTrace();
        return map;
    }
}

[Buggy Hunk]
String foreign = st.nextToken().trim().toLowerCase();

[Patch]
String foreign = st.nextToken().trim();