public static synchronized Properties getConfigFile(String path)
{
private static Properties ConfigProperties = new Properties();
String configPath = path;
File file = new File(configPath);
BufferedInputStream propertyStream = null;
FileInputStream fis = null;
try
{
if (file.exists())
{
fis = new FileInputStream(configPath);
propertyStream = new BufferedInputStream(fis);
ConfigProperties.load(propertyStream);
return ConfigProperties;
}
else
{
return null;
}
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
finally
{
closeHandle(fis, propertyStream);
}
}
{
private static Properties ConfigProperties = new Properties();
String configPath = path;
File file = new File(configPath);
BufferedInputStream propertyStream = null;
FileInputStream fis = null;
try
{
if (file.exists())
{
fis = new FileInputStream(configPath);
propertyStream = new BufferedInputStream(fis);
ConfigProperties.load(propertyStream);
return ConfigProperties;
}
else
{
return null;
}
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
finally
{
closeHandle(fis, propertyStream);
}
}
获取配置文件的Java方法
本文介绍了一种使用Java实现的获取配置文件的方法,通过检查文件是否存在并加载配置信息到Properties对象中。
1836

被折叠的 条评论
为什么被折叠?



