您的位置:首页 > 编程语言 > Java开发

myeclipse写配置文件,在程序里找到路径,并读取配置文件的内容

2013-03-17 00:06 357 查看
写配置文件,在程序里找到路径,并读取配置文件的内容:

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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: