//方法1:从.properties文件中读取信息
Properties prop = new Properties();
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsSteam("文件名");
try
{
prop.load(in);
}
catch (IoException e)
{
e.printStackTrace();
}
String name = prop.getProperty("属性名");
//方法2:从.properties文件中读取信息
private static String fileName;//定义了一个变量
static {
Properties pro = new Properties();
InputStream in = Logger.class.getClassLoader().getResourceAsStream(
"Logger.properties");//Logger.properties,从这个文件中读取我们需要的文件
try {
pro.load(in);
fileName = pro.getProperty("FileName");
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}