读取配置文件

//读取配置文件
Properties prop = new Properties();
//InputStream in = Object. class .getResourceAsStream(("/lainxiti/Url.properties" ));
String cd="";
String cd1 ="";
String cd2 ="";
String cd3 ="";
String cd4 ="";
String cd5 ="";
String cd6 ="";
String cd7 ="";
String cd8 ="";
String mess1 ="";
try {
prop.load(new InputStreamReader(Object.class.getResourceAsStream("/lainxiti/Url.properties"), "UTF-8")); //

//prop.load(in);
cd = prop.getProperty("cd").trim();
cd1 = prop.getProperty("cd1").trim();
cd2 = prop.getProperty("cd2").trim();
cd3 = prop.getProperty("cd3").trim();
cd4 = prop.getProperty("cd4").trim();
cd5 = prop.getProperty("cd5").trim();
cd6 = prop.getProperty("cd6").trim();
cd7 = prop.getProperty("cd7").trim();
cd8 = prop.getProperty("cd8").trim();
mess1 = prop.getProperty("mess1").trim();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//==end==

原文地址:https://www.cnblogs.com/alomsc/p/10579520.html