JSP+Java+properties+FileInputStream文件读写,JSP页面读取properties文件
2024-10-17 00:27:22
String realPath = request.getRealPath("WEB-INF/classes/com/properties/devicetype.properties");
以上为获取路径的最正确做法,因此,properties可以放在com包下,或者src目录下。
Properties props = new Properties();
ArrayList al = new ArrayList();
try {
InputStream in = new BufferedInputStream (new FileInputStream(realPath));
props.load(in);
Enumeration en = props.propertyNames(); while (en.hasMoreElements()) {
String key = (String) en.nextElement();
String Property = props.getProperty (key);
al.add(Property);
//System.out.println(key+Property);
}
} catch (Exception e) {
e.printStackTrace();
}
以上代码可以成功从指定目录下读取properties配置文件的key和value值,并按照相关业务做相关处理。
欢迎关注微博:http://weibo.com/cxais
最新文章
- xpath tutorial
- LDA(文档主题模型)
- contentResolver
- KendoUI之kendoGrid服务端分页
- [转]浏览器渲染机制——一定要放在body底部的js引用
- Linux嵌入式入门
- Unity动画
- 51nod1175 区间中第K大的数
- OpenDaylight之openflowjava的编译
- python学习之路-4 内置函数和装饰器
- Webserver管理系列:9、创password重设盘
- MYSQL数据库学习十 单表数据记录查询
- android 实现点击edittext的“小眼睛”切换明密文
- 关于php
- 使用yield返回IEnumber<;T>;集合
- POJ 3126 Prime Path (素数+BFS)
- ABBYY OCR技术教电脑阅读缅甸语(下)
- [11]Windows内核情景分析---设备驱动
- json的内容回顾
- 精神状态: Confused
热门文章
- 经纪xx系统节点VIP案例介绍和深入分析异常
- linux下串口调试工具/串口终端推荐: picocom
- LVM 命令集总结(转)
- 基于Gsoap 的ONVIF C++ 库
- Grant的时候报错的解决:Access denied for user &;#39;root&;#39;@&;#39;localhost&;#39; (using password: YES)
- 左右TS分析流
- C#+Mapxtreme 实现一些GIS系统基本的功能
- POJ--2289--Jamie&;#39;s Contact Groups【二分图的多个匹配+二分法答案】
- Redis源代码分析(二十)--- ae事件驱动
- Codeforces 437A The Child and Homework