package me.ilt.Blog.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
public class PropertiesUtil {
public static String getValue(String key){
Properties prop = new Properties();
try {
//装载配置文件
prop.load(new FileInputStream(new File("src//dbCfg.properties")));
} catch (IOException e) {
e.printStackTrace();
}
//返回获取的值
return prop.getProperty(key);
}
/*public static void main(String[] args) {
System.out.println(getValue("dbUser"));
}*/
}
package me.ilt.Util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class PropertiesUtil {
public static String getValue(String key){
Properties prop = new Properties();
InputStream in = new PropertiesUtil().getClass().getResourceAsStream("/dbCfg.properties");
try {
prop.load(in);
} catch (IOException e) {
e.printStackTrace();
}
return prop.getProperty(key);
}
}