写配置文件,在程序里找到路径,并读取配置文件的内容:
String classPath = this.getClass().getClassLoader().getResource("/").getPath(); //得到当前路径
FileInputStream fin = new FileInputStream(classPath+"portconfig");//读取配置文件路径,portconfig为文件名
Properties pr = new Properties();
pr = new Properties();
pr.load(fin);
ServicePort = pr.getProperty("SERVICEPORT"); //读取参数,ServicePort 参数
fin.close();
pr = null;
fin = null;
myeclipse写配置文件,在程序里找到路径,并读取配置文件的内容
最新推荐文章于 2021-09-05 00:53:57 发布