csv文件内容如下,第一行是文件头

解析代码如下:

package com.xxx;

import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; @Data
public class CodecRegistries {
private String index;
private String name;
/**
* WAVE form Registration Number
*/
private Integer hex;
/***
* Codec ID in the IANA Namespace
*/
private String mimeType; /***
* WAVE form wFormatTag ID
*/
private String wFormatTag; /***
* WAVEFORMAT Use
*/
private String use; /***
* WAVEFORMAT Name
*/
private String formatName; /***
* WAVEFORMAT Description
*/
private String descr; /***
* Additional Information
*/
private String additional; /***
*
*/
private String contact; @Override
public String toString() {
return new ToStringBuilder(this)
.append("index", index)
.append("name", name)
.append("hex", hex)
.append("mimeType", mimeType)
.append("wFormatTag", wFormatTag)
.append("use", use)
.append("formatName", formatName)
.append("descr", descr)
.append("additional", additional)
.append("contact", contact)
.toString();
}
}
static Map<Integer,CodecRegistries> codes = new HashMap<>();

 static void readCodeRegistries(String fileName)
{
try (InputStream inputStream = new FileInputStream(fileName)) { FileSource source = FileSource.of(inputStream); CsvParserConfig config = CsvParserConfig.builder()
.charset(StandardCharsets.UTF_8)
.build(); Map<Integer, CodecRegistries> map = Windmill.parse(source, Parsers.csv(config)).skip(1).map(row -> {
CodecRegistries registration = new CodecRegistries(); registration.setIndex(row.cell(0).asString());
registration.setName(row.cell(1).asString());
          //通过自定义数据转换代码,将16进制数0x0001这样的数值转换成Integer
Integer hex = new NumberValue<Integer>(row.cell(2).asString(), hexDecimal -> Integer.decode(hexDecimal)).value(); registration.setHex(hex);
registration.setMimeType(row.cell(3).asString());
registration.setWFormatTag(row.cell(4).asString());
registration.setUse(row.cell(5).asString());
registration.setFormatName(row.cell(6).asString());
registration.setDescr(row.cell(7).asString());
registration.setAdditional(row.cell(8).asString());
registration.setContact(row.cell(9).asString());
return registration; }).collect(Collectors.toMap(CodecRegistries::getHex, Function.identity()));
codes.putAll(map);
}catch (IOException e){
System.err.println(e);
}
}

最新文章

  1. MySQL 数据库主从复制架构
  2. 分布式监控系统Zabbix-3.0.3-完整安装记录(2)-添加mysql监控
  3. CSS零基础学习笔记.
  4. SQL Server调优系列玩转篇(如何利用查询提示(Hint)引导语句运行)
  5. 开发常用小demo 整理
  6. HDU1695 GCD (欧拉函数+容斥原理)
  7. 计算webView的 高度 和自适应屏幕大小
  8. iosUITextField属性
  9. 多线程下OpenCV操作的问题
  10. Qt播放mp3
  11. C++虚表(V-Table)解析
  12. [图解Java]ReentrantLock重入锁
  13. jenkins添加类ubuntu/centos节点报错
  14. dskinlite(uieasy mfc界面库)使用记录3:绘制动态元素(按钮控件通过隐藏方式修改图片显示)
  15. HackerRank beautiful string
  16. js中 switch 注意事项
  17. JAVAEE——SpringBoot入门:简介、微服务、环境准备、helloworld与探究、快速构建项目
  18. 一次性解决Intellij IDEA maven 自动跳到1.5的JDK
  19. Spark的机器学习算法mlib的例子运行
  20. 批量导入数据到mssql数据库的

热门文章

  1. django 新项目
  2. Java&amp;Selenium数据驱动【DataProvider+TestNG+Csv】
  3. #Python绘制 文本进度条,带刷新、时间暂缓的
  4. linux服务器日志剖析
  5. JavaScript基础习题
  6. JAVA开发WEBSERVICE方式
  7. python numpy.array插入一行或一列
  8. 组件化网页开发 / 步骤二 &#183; 2-11 jquery的ajax方法 以及下一章跨域没懂
  9. Linux下的电路设计辅助软件
  10. 【原创】go语言学习(一)