[Demonstration 1]

[Buggy Method]
public static boolean hasFilteredDealerships(DBHelper dbh, String userId) {
    Cursor c = null;
    SQLiteDatabase db = dbh.getReadableDatabase();
    boolean result = false;
    try {
        String query = "select * from " + DBHelper.DEALERSHIPS_SELECTED_TABLE_NAME + " where " + DEALERSHIPS_COLUMN_USER_ID + " = ?";
        c = db.rawQuery(query, new String[] { userId });
        int count = c.getCount();
        boolean test = count > 1;
        if (test) {
            result = true;
        }
    } finally {
        if (c != null) {
            c.close();
        }
        if (db != null) {
            db.close();
        }
        return result;
    }
}

[Buggy Hunk]
boolean test = count > 1;

[Patch]
boolean test = count > 0;

[Demonstration 2]

[Buggy Method]
public boolean createDataFiles() {
    boolean exists = false;
    try {
        if (!cards.exists())
            cards.createNewFile();
    } catch (IOException e) {
        System.out.println("Problem creating file.");
    }
    exists = checkIfFilesExist();
    return exists;
}

[Buggy Hunk]
if (!cards.exists())

[Patch]
if (!cards.isFile())

[Demonstration 3]

[Buggy Method]
private void loadCourses(File dir) throws FileNotFoundException {
    if (!dir.isDirectory()) {
        throw new FileNotFoundException("Parameter is no directory");
    }
    if (!dir.exists()) {
        throw new FileNotFoundException("Specified directory not found");
    }
    List<Course> lst = new ArrayList<Course>();
    for (File file : dir.listFiles()) {
        try {
            Course c = null;
            if (file.isDirectory()) {
                if (!file.getName().startsWith(".")) {
                    c = xmlCourseSerializer.load(file);
                }
            } else {
                if (file.getName().endsWith("." + ZipCourseSerializer.DEFAULT_FILE_EXTENSION)) {
                    c = xmlCourseSerializer.load(file);
                }
            }
            if (c != null) {
                lst.add(c);
                logger.debug("loaded course \"" + file + "\" successfully");
            } else {
                logger.info("unable to load file \"" + file + "\"");
            }
        } catch (NullPointerException e) {
            logger.warn("loading course \"" + file + "\" caused a NullPointerException");
        } catch (IOException e) {
            logger.warn("loading course \"" + file + "\" caused a IOException");
        } catch (NonogramFormatException e) {
            logger.warn("loading course \"" + file + "\" caused a NonogramFormatException");
        } catch (CourseFormatException e) {
            logger.warn("loading course \"" + file + "\" caused a CourseFormatException");
        }
    }
    this.courseList = lst;
}

[Buggy Hunk]
c = xmlCourseSerializer.load(file);

[Patch]
c = zipCourseSerializer.load(file);