make inputstream auto-closeable

This commit is contained in:
Ingmar Goudt 2018-09-28 15:29:41 +02:00
parent 3653e09ce4
commit 22c072ad93

View file

@ -2,6 +2,7 @@ package mage.utils.properties;
import org.apache.log4j.Logger;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
@ -19,39 +20,36 @@ public final class PropertiesUtil {
private static Properties properties = new Properties();
static {
InputStream in = PropertiesUtil.class.getResourceAsStream("/xmage.properties");
if (in != null) {
try {
properties.load(in);
} catch (IOException e) {
logger.error("Couldn't load properties", e);
}
} else {
try (InputStream in = PropertiesUtil.class.getResourceAsStream("/xmage.properties")) {
properties.load(in);
} catch (FileNotFoundException fnfe) {
logger.warn("No xmage.properties were found on classpath");
} catch (IOException e) {
logger.error("Couldn't load properties");
e.printStackTrace();
}
}
/**
* Hide constructor
*/
/**
* Hide constructor
*/
private PropertiesUtil() {
}
public static String getDBLogUrl() {
String url = properties.getProperty(PropertyKeys.KEY_DB_LOG_URL, LOG_JDBC_URL);
if (url != null) {
return url.trim();
}
return null;
}
public static String getDBFeedbackUrl() {
String url = properties.getProperty(PropertyKeys.KEY_DB_FEEDBACK_URL, FEEDBACK_JDBC_URL);
if (url != null) {
return url.trim();
public static String getDBLogUrl () {
String url = properties.getProperty(PropertyKeys.KEY_DB_LOG_URL, LOG_JDBC_URL);
if (url != null) {
return url.trim();
}
return null;
}
public static String getDBFeedbackUrl () {
String url = properties.getProperty(PropertyKeys.KEY_DB_FEEDBACK_URL, FEEDBACK_JDBC_URL);
if (url != null) {
return url.trim();
}
return null;
}
return null;
}
}