@ 在项目路径下创建一个text:
jco.client.ashost=host
jco.client.client=client
保存另存为user.properties
@
public static void main(String[] args) throws SQLException, IOException {
String currpath = new File("").getAbsolutePath()
+"\user.properties"; //获取属性文件的绝对路径
System.out.println(currpath);
Properties prop = new Properties();
InputStream in;
try {
in = new FileInputStream(new File(currpath));//读属性文件
if(in != null){
prop.load(in);
String ashost = prop.getProperty("jco.client.ashost");
String clientnr = prop.getProperty("jco.client.client");
System.out.println(ashost);
System.out.println(clientnr);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}