LoadProperties读取配置文件:
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class LoadProperties {
private static Properties properties;
public static String getValueByKey(String fileName,String key){
properties = new Properties();
InputStream inStream= loadProperties(fileName);
try {
properties.load(inStream);
return properties.getProperty(key);
} catch (IOException e) {
e.printStackTrace();
return "";
}
}
private static InputStream loadProperties(String fileName){
return LoadProperties.class.getClassLoader().getResourceAsStream(fileName);
}
}