public class ConfigurableConstants {
protected static final Properties p = new Properties();
protected static void init(String propertyFileName) {
InputStream in = null;
try {
in = ConfigurableConstants.class.getClassLoader()
.getResourceAsStream(propertyFileName);
if (in != null)
p.load(in);
} catch (IOException e) {
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
}
}
}
}
protected static String getProperty(String key, String defaultValue) {
return p.getProperty(key, defaultValue);
}
}
调用
static {
init("cssisupport/cssisupport.properties");
}
public static final String SEARCH = getProperty("search", "");
protected static final Properties p = new Properties();
protected static void init(String propertyFileName) {
InputStream in = null;
try {
in = ConfigurableConstants.class.getClassLoader()
.getResourceAsStream(propertyFileName);
if (in != null)
p.load(in);
} catch (IOException e) {
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
}
}
}
}
protected static String getProperty(String key, String defaultValue) {
return p.getProperty(key, defaultValue);
}
}
调用
static {
init("cssisupport/cssisupport.properties");
}
public static final String SEARCH = getProperty("search", "");