class FileListJsonBuilder {

    public String buildLogFileListJson(final File directory) {
        String result = "{\"files\":[]}";
        String[] messageFiles = directory.list();
        if (messageFiles != null) {
            Arrays.sort(messageFiles);
            result = getJson(messageFiles);
        } else {
            logger.debug("The directory '" + directory + "' has not been created yet, or an I/O error occured.");
        }
        return result;
    }

}