[Demonstration 1]

[Buggy Method]
public static String readFile(File file) {
    StringBuffer content = new StringBuffer();
    if (file != null && file.exists()) {
        BufferedReader br = null;
        String line = null;
        try {
            br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
            if ((line = br.readLine()) != null) {
                content.append(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    return content.toString();
}

[Buggy Hunk]
if ((line = br.readLine()) != null) {

[Patch]
while ((line = br.readLine()) != null) {

[Demonstration 2]

[Buggy Method]
@Override
public boolean switchTwoLines(int index1, int index2) throws IOException {
    if (index1 < 1 || index2 < 1) {
        log.log(Level.WARNING, "index1 < 1 or index2 < 1");
        throw new IllegalArgumentException();
    }
    ArrayList<String> lines = (ArrayList) Files.readAllLines(file.toPath());
    // because we count lines from 1
    Collections.swap(lines, index1 - 1, index2 - 1);
    // validate all lines
    if (!validateLines(lines)) {
        System.err.println("After switching this file contains errors. Switch operation FAILED");
        return false;
    }
    writeLines(lines);
    return true;
}

[Buggy Hunk]
ArrayList<String> lines = (ArrayList) Files.readAllLines(file.toPath());

[Patch]
ArrayList<String> lines = (ArrayList<String>) Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);

[Demonstration 3]

[Buggy Method]
public void send(String data) throws UnsupportedEncodingException {
    log.trace("send message: {}", data);
    Packet packet = Packet.build(data.getBytes(), MessageType.TEXT);
    session.write(packet);
}

[Buggy Hunk]
Packet packet = Packet.build(data.getBytes(), MessageType.TEXT);

[Patch]
Packet packet = Packet.build(data.getBytes("UTF8"), MessageType.TEXT);