String DBhost="";
int selectCount;
Properties prop = new Properties();
InputStream in;
in = getClass().getResourceAsStream("a.properties");//平級,classes下
prop.load(in);
Set keyValue = prop.keySet();
for (Iterator it = keyValue.iterator(); it.hasNext();) {
String key = (String) it.next();
if (key.equals("DBhost")) {
DBhost = (String) prop.get(key);
} else if (key.equals("selectCount")){
selectCount =Integer.parseInt((String)prop.get(key));
}
}
a. properties
DBhost=localhost
selectCount=2000