private static final String RES_FILE_PATH ="resources_file.properites";
private int readPropertiesValue(final String key) private int readPropertiesValue(final String key) throws IOException {
InputStream inputStream = null;
final Properties props = new Properties();
try {
inputStream = Thread.currentThread().getContextClassLoader()
.getResourceAsStream(RES_BACKYARD_FILE);
// inputStream = this.getClass().getClassLoader().getResourceAsStream(RES_BACKYARD_FILE);
// 這個方法不能使用在 靜態模塊中獲取ClassLoader。
props.load(inputStream);
final String valueStr = props.getProperty(key);
int returnValue = 0;
if (valueStr != null) {
returnValue = Integer.valueOf(valueStr);
}
return returnValue;
} finally {
if (inputStream != null) {
inputStream.close();
}
}
}