mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
make inputstream auto-closeable
This commit is contained in:
parent
3653e09ce4
commit
22c072ad93
1 changed files with 24 additions and 26 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue