读取配置文件数据
来源:互联网 发布:医学影像工作站软件 编辑:程序博客网 时间:2024/06/17 05:49
读取配置文件数据
读取java工程里面的.text、.properties文件的代码
private static List<Record> load(String filePath) {File inFile = new File(filePath);InputStreamReader read = null;final List<Record> list = new ArrayList<Record>(256);try {read = new InputStreamReader(new FileInputStream(inFile), "utf-8");BufferedReader bufferedReader = new BufferedReader(read);String lineTxt = null;Record record = null;while ((lineTxt = bufferedReader.readLine()) != null) {record = parse(lineTxt);list.add(record);}} catch (Exception e) {e.printStackTrace();} finally {if(read != null) {try {read.close();} catch (IOException e) {}}}return list;}附:解析封装进record类
protected static Record parse(String lineTxt) {Record record = new Record();String[] arr = lineTxt.split(",");record.setKey(arr[0]);record.setAccAccurateRate(arr[1]); record.setCheckAccSuccessRate(arr[2]);record.setDealSuccessRate(arr[3]);record.setInflationRate("1");return record;}
附:.txt文件内容
2013-03,99.91,99.91,99.912013-04,99.92,99.98,99.992013-05,99.94,99.92,99.982013-06,99.90,99.95,99.962013-07,99.94,99.96,99.982013-08,99.91,99.93,99.922013-09,99.92,99.90,99.922013-10,99.90,99.98,99.982013-11,99.92,99.92,99.952013-12,99.97,99.93,99.92
附:record封装对象
自己定义-四个字段
附:将text里面封装成List<record> 转成 Map<String, Record> 格式;
Map<String, Record> MONTH_DS = new ConcurrentHashMap<String, Record>(56);
mRecord是含有txt数据的 List<record>
for (int i = 0; i < monthRs.size(); i++) {<span style="white-space:pre"></span>mRecord = monthRs.get(i);<span style="white-space:pre"></span>MONTH_DS.put(mRecord.getKey(), mRecord);<span style="white-space:pre"></span>}转化完成!
new ConcurrentHashMap<String, Record>(56) 里面有一个方法 .containKey判断是不是含有某一个key值
最后 附:env 控制台出现这个需要配置环境变量,将工程通用的配置文件配置成环境变量
0 0
- 读取配置文件中的数据
- 如何读取配置文件数据
- 读取配置文件数据
- 读取XML配置文件数据
- thinkphp读取配置文件中的数据
- 【Xml配置文件的数据读取】
- 从配置文件中读取数据
- java中从配置文件中读取数据
- 读取***.properties配置文件里数据的方法
- 向INI配置文件写入\读取数据
- javascript读取.xml配置文件里的数据
- java 读取和写入配置文件中的数据
- Function调用PropUtil读取配置文件数据
- MFC/C++读取配置文件ini的数据
- 学习:C#读取ini配置文件数据
- @PropertiesSource注解读取配置文件中的数据
- C# 定义配置文件 使程序在配置文件中读取数据
- 向空文件写数据,并读取配置文件数据
- PopupWindow 用法 PopupWindow不消失 解决方法
- Android支付接入(一):支付宝
- Jcrop裁剪图片[一] :前端js总结
- 在Android 4.0以下机型上支持webp编码和解码
- char * 与 nsstring 转换
- 读取配置文件数据
- 程序缩小到托盘后系统就无法关机(解决方案)
- 华为说企业使用windows连肉末都吃不到
- 最大流最小割定理
- Eclipse恢复默认设置
- jsonp跨域请求数据实例——手机号码查询
- 拉普拉斯算子(转)
- cocos2dx判断一个点是否在三角形中
- web.xml中的url-pattern照射规则