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

最新文章

  1. xpath tutorial
  2. LDA(文档主题模型)
  3. contentResolver
  4. KendoUI之kendoGrid服务端分页
  5. [转]浏览器渲染机制——一定要放在body底部的js引用
  6. Linux嵌入式入门
  7. Unity动画
  8. 51nod1175 区间中第K大的数
  9. OpenDaylight之openflowjava的编译
  10. python学习之路-4 内置函数和装饰器
  11. Webserver管理系列:9、创password重设盘
  12. MYSQL数据库学习十 单表数据记录查询
  13. android 实现点击edittext的“小眼睛”切换明密文
  14. 关于php
  15. 使用yield返回IEnumber<T>集合
  16. POJ 3126 Prime Path (素数+BFS)
  17. ABBYY OCR技术教电脑阅读缅甸语(下)
  18. [11]Windows内核情景分析---设备驱动
  19. json的内容回顾
  20. 精神状态: Confused

热门文章

  1. 经纪xx系统节点VIP案例介绍和深入分析异常
  2. linux下串口调试工具/串口终端推荐: picocom
  3. LVM 命令集总结(转)
  4. 基于Gsoap 的ONVIF C++ 库
  5. Grant的时候报错的解决:Access denied for user 'root'@'localhost' (using password: YES)
  6. 左右TS分析流
  7. C#+Mapxtreme 实现一些GIS系统基本的功能
  8. POJ--2289--Jamie's Contact Groups【二分图的多个匹配+二分法答案】
  9. Redis源代码分析(二十)--- ae事件驱动
  10. Codeforces 437A The Child and Homework