import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
* @author dchen
* @date 2013-6-21 上午09:26:17
*/
public class PropertyUtil {
public static String getValueByProperty(String key)
{
Properties p = new Properties();
try {
InputStream in = PropertyUtil.class.getResourceAsStream("/config/chat_config.properties");
p.load(in);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
String path = p.getProperty(key);
return path;
}
public static String getValueByProperty(String key, String filePath)
{
Properties p = new Properties();
String defaultPath = "/config/chat_config.properties";
if (filePath == null)
filePath = defaultPath;
try
{
InputStream in = PropertyUtil.class.getResourceAsStream(filePath);
p.load(in);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
String path = p.getProperty(key);
return path;
}
}
PropertyUtil
最新推荐文章于 2023-12-16 13:30:00 发布