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;
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;
相关文章推荐
- VC程序读取配置文件内容
- 使用程序来读取xml配置文件的内容
- 在电脑上找到这个路径:D:\jakarta-tomcat-6\conf\Catalina,将localhost目录直接删除掉,再一运行,就没事了! 因为配置文件中配置了启动程序,而webapps文件夹下却没有此应用程序,所以出现了上述错误。
- JAVA开发10--加载相对路径下配置文件并读取内容
- C++从配置文件读取路径,然后在程序中使用的方法
- linux下读取简单文本配置文件C程序
- 【Spring学习笔记-2】Myeclipse下第一个Spring程序-通过ClassPathXmlApplicationContext加载配置文件
- vc读取当前路径和读取配置ini文件
- winform程序读取和改写配置文件App.config元素的值
- winform程序读取和改写配置文件App.config元素的值
- java读取工程配置文件内容
- 如何读取xml配置文件的内容
- java对【配置文件的读取】与【读配置文件时的路径问题】代码总结
- 关于系统读取properties配置文件的路径问题,包括打成jar包的运行文件
- RCP中Properties文件路径和内容读取
- Android下一种打开并读取指定路径文件内容的方法
- ini 配置文件读取程序(C语言)
- jdbc java数据库连接 6)类路径读取——JdbcUtil的配置文件
- 文件路径读取内容
- Java程序中的配置文件的存放和读取