//其他类调用的方法
PropertiesConfig config = new PropertiesConfig();
config.setPropertiesDataSource("/jdbc.properties");
config.getString("dataSource_driverClass");
//读properties配置文件的java类
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class PropertiesConfig {
private Properties prop;
public void setPropertiesDataSource(String url){
prop = new Properties();
InputStream inputStream=getClass().getResourceAsStream(url);
try {
prop.load(inputStream);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new RuntimeException(e);
}
}
public Integer getInteger(String key){
return Integer.parseInt(prop.getProperty(key));
}
public String getString(String key){
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载