-
Notifications
You must be signed in to change notification settings - Fork 74
读文件之简单读取
quhongwei edited this page Mar 28, 2018
·
1 revision
总笔数:100|总金额:300.03
流水号|基金公司订单号|订单申请时间|普通日期|普通日期时间|普通数字|金额|年龄|长整型|布尔值|备注
seq_0|inst_seq_0|2013-11-09 12:34:56|20131109|20131112 12:23:34|23.33|10.22|22|12345|true|备注1
seq_1|inst_seq_1|2013-11-10 15:56:12|20131110|20131113 12:33:34|23.34|11.88|33|56789|false|
OFDCFEND|20131109|100
{
"head":[
"totalCount|总笔数|Required|Long",
"totalAmount|总金额|BigDecimal|Required"
],
"body":[
"seq|流水号",
"instSeq|基金公司订单号|Required",
"gmtApply|订单申请时间|Date:yyyy-MM-dd HH:mm:ss",
"date|普通日期|Date:yyyyMMdd",
"dateTime|普通日期时间|Date:yyyyMMdd HH:mm:ss",
"applyNumber|普通数字|BigDecimal",
"amount|金额|BigDecimal",
"age|年龄|Integer",
"longN|长整型|Long",
"bol|布尔值|Boolean",
"memo|备注"
],
"tail": [
"fileEnd|数据文件尾部字符",
"date|普通日期|Date:yyyyMMdd",
"amount|金额|BigDecimal"
],
"protocol":"DE"
}
DE组件内置协议
1.读取数据都会转成 HashMap实例
2.HashMap的key是数据定义模板中key
FileConfig config = new FileConfig(“文件路径”, "数据定义模板路径", new StorageConfig("nas"));
FileReader fileReader = FileFactory.createReader(config);
try {
Map<String, Object> tail = fileReader.readTail(HashMap.class);
Map<String, Object> head = fileReader.readHead(HashMap.class);
Map<String, Object> row = null;
while (null != (row = fileReader.readRow(HashMap.class)) {
// 处理业务
}
} finally {
fileReader.close();
}