class MessageFileCounter {

    public int getCountOfMessages() {
        int result;
        getMessagesFolderPath();
        try {
            File folder = new File(messagesFolderPath);
            folder = folder.getAbsoluteFile();
            result = folder.listFiles().length;
        } catch (NullPointerException e) {
            logger.debug(FOLDER_ERROR_MESSAGE, e);
            //this may happen only at the start of a brand new Wilma instance, and this solution is still better than executing the if statement forever and ever
            result = 0;
        }
        return result;
    }

}