All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.braintreegateway.util.ClientLibraryProperties Maven / Gradle / Ivy

There is a newer version: 3.32.0_1
Show newest version
package com.braintreegateway.util;

import com.braintreegateway.exceptions.UnexpectedException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ClientLibraryProperties {

    public static final String BRAINTREE_PROPERTY_FILE = "braintree.properties";
    public static final String VERSION_PROPERTY_NAME = "braintree.gateway.version";

    private final Properties properties = loadProperties(BRAINTREE_PROPERTY_FILE);

    public String version() {
        return properties.getProperty(VERSION_PROPERTY_NAME);
    }

    private Properties loadProperties(String propertyFile) {
        try {
            InputStream is = null;
            try {
                is = getClass().getClassLoader().getResourceAsStream(propertyFile);
                Properties p = new Properties();
                p.load(is);
                return p;
            } finally {
                if (is != null) {
                    is.close();
                }
            }
        } catch (IOException e) {
            throw new UnexpectedException("Couldn't load " + BRAINTREE_PROPERTY_FILE + " can't continue", e);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy