import java.io.InputStream;
import java.util.Properties;
public class FileProperties
extends Properties{
public FileProperties(){}
public FileProperties(String s)
{
try
{
InputStream inputStream =
getClass().getResourceAsStream(s);
load(inputStream);
inputStream.close();
}catch (Exception e)
{
System.err.println("Exception in FileProperties(String): "
+
e.toString()
+ " for filename="
+
s);
}
}
public FileProperties(Properties properties) {
super(properties);
}
public static String getMyProperty(String name){
FileProperties fp =
new FileProperties("/cms.properties"
);
if ( fp !=
null ) {
return fp.getProperty(name);
} else {
return null;
}
}
}
属性配置文件cms.properties格式为:
#Socket_TIM_Z = 0 47 17 * * ?
Socket_TIM_J = 0 0 4 * * ?
Socket_TIM_ZZH = 2 * * ? * *
转载于:https://www.cnblogs.com/fengyunyue/p/5948067.html
相关资源:数据结构—成绩单生成器