web项目读写src目录下的.properties文件
来源:互联网 发布:易语言微信加好友源码 编辑:程序博客网 时间:2024/05/17 08:40
针对放在WebRoot目录下的properties文件
1.读properties文件
Properties pro = new Properties();
pro.load(ConfigServlet.class.getResourceAsStream("/config.properties"));
pro.getProperty("key");
2.写properties
Properties pro = new Properties();
pro.setProperty("key", "value");
FileOutputStream fos = new FileOutputStream(this.class.getResource("/config.properties").getPath());
pro.store(fos, "comments");
针对放置于src目录下的properties文件
src目录下的properties文件,编译后会放置于classes目录下,读取的时候可以使用
1. XX.class.getResourceAsStream("/config.properties");
2. new FileInputSteam("/config.properties")
这两种方式。
写入的时候使用new FileOutputStream("/config.properties")方式获取文件流。
0 0
- web项目读写src目录下的.properties文件
- java读写src目录下的properties文件
- Java web 项目读取src或者tomcat下class目录下的xml文件或者properties文件
- scala学习-12-scala读取java项目下Src目录下的properties文件
- 读取web项目web-inf目录下的jdbc.properties文件
- web项目中读取web-inf下的properties文件
- Java读取src目录下的properties配置文件
- Properties文件不在项目目录下的一种读取方法
- 获取项目src下的目录
- web项目 读取src下的配置文件
- java web项目获取src和WebContent目录下的配置文件
- 关于在Winodws/Linux下Web项目获取src目录下文件路径的方法
- java获取src下的properties文件的值
- android下properties文件的读写操作
- android下properties文件的读写操作
- properties文件的读写
- .properties 文件的读写
- jsp项目读取src目录下的配置文件
- 探索应用开发的基础之android源文件的组织
- 61E Enemy is weak
- Can't create handler inside thread that has not called Looper.prepare()问题解决
- C++高质量编程学习笔记(3)
- 扩展 TableAdapter 的功能
- web项目读写src目录下的.properties文件
- 文件夹病毒入侵电脑后解决办法
- 字符指针的问题
- 預防 Android Dex 64k Method Size Limit
- 改变UITabBar的背景色
- 13、Notification与多线程
- Unity3D开发(五):Unity3D 4.x 使用Mecanim实现连击
- 二分查找算法(折半查找算法)
- 原题的价值 出题人:VFleaking hnoi2015 集训