<commit_before>package cc.blynk.common.utils;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Properties;

/**
 * The Blynk Project.
 * Created by <NAME>.
 * Created on 2/12/2015.
 */
public class PropertiesUtil {

    private static final Logger log = LogManager.getLogger(PropertiesUtil.class);

    /**
     * Util class. first loads properties file from class path after that from current folder.
     * So properties file in current folder is always overrides properties in classpath.
     *
     * @param filePropertiesName - name of properties file, for example "twitter4j.properties"
     * @return - loaded properties
     */
    public static Properties loadProperties(String filePropertiesName) {
        if (!filePropertiesName.startsWith("/")) {
            filePropertiesName = "/" + filePropertiesName;
        }
        Properties props = new Properties();
        try (InputStream classPath = PropertiesUtil.class.getResourceAsStream(filePropertiesName);
             InputStream curFolder = Files.newInputStream(Paths.get(System.getProperty("user.dir"), filePropertiesName))) {

            if (classPath != null) {
                props.load(classPath);
            }
            if (curFolder != null) {
                props.load(curFolder);
            }
        } catch (Exception e) {
            log.error("Error getting '{}' properties file.", filePropertiesName, e);
        }
        return props;
    }

    public static int getIntProperty(Properties props, String propertyName) {
        return ParseUtil.parseInt(props.getProperty(propertyName));
    }

    public static long getLongProperty(Properties props, String propertyName) {
        return ParseUtil.parseLong(props.getProperty(propertyName));
    }

}<commit_msg>Better exception handling<commit_after>package cc.blynk.common.utils;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Properties;

/**
 * The Blynk Project.
 * Created by <NAME>.
 * Created on 2/12/2015.
 */
public class PropertiesUtil {

    private static final Logger log = LogManager.getLogger(PropertiesUtil.class);

    /**
     * Util class. first loads properties file from class path after that from current folder.
     * So properties file in current folder is always overrides properties in classpath.
     *
     * @param filePropertiesName - name of properties file, for example "twitter4j.properties"
     * @return - loaded properties
     */
    public static Properties loadProperties(String filePropertiesName) {
        if (!filePropertiesName.startsWith("/")) {
            filePropertiesName = "/" + filePropertiesName;
        }
        Properties props = new Properties();
        try (InputStream classPath = PropertiesUtil.class.getResourceAsStream(filePropertiesName)) {
            if (classPath != null) {
                props.load(classPath);
            }
        } catch (Exception e) {
            log.error("Error getting '{}' properties file.", filePropertiesName, e);
        }

        Path curDirPath = Paths.get(System.getProperty("user.dir"), filePropertiesName);
        if (Files.exists(curDirPath)) {
            try (InputStream curFolder = Files.newInputStream(curDirPath)) {
                if (curFolder != null) {
                    props.load(curFolder);
                }
            } catch (Exception e) {
                log.error("Error getting '{}' properties file.", filePropertiesName, e);
            }
        }

        return props;
    }

    public static int getIntProperty(Properties props, String propertyName) {
        return ParseUtil.parseInt(props.getProperty(propertyName));
    }

    public static long getLongProperty(Properties props, String propertyName) {
        return ParseUtil.parseLong(props.getProperty(propertyName));
    }

}
{'fraction_non_alphanumeric': 0.09943530567149521, 'fraction_numerical': 0.004910385465259023, 'mean_word_length': 2.751381215469613, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6646226', 'n_tokens_mistral': 1060, 'n_tokens_neox': 1038, 'n_words': 275}