惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
有赞技术团队
有赞技术团队
IT之家
IT之家
博客园 - 聂微东
Jina AI
Jina AI
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
小众软件
小众软件
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
Visual Studio Blog
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
阮一峰的网络日志
阮一峰的网络日志
宝玉的分享
宝玉的分享
博客园 - 三生石上(FineUI控件)
大猫的无限游戏
大猫的无限游戏
博客园 - Franky
量子位
月光博客
月光博客
博客园 - 【当耐特】
博客园 - 叶小钗

博客园 - cndavy

如何在WINDOW环境下搭建ActivateMQ和zookeeper集群环境 Esp8266 例子 树莓派 安装 docker 切换网卡的脚本 apache xampp 目录防止解析php FTPS 客户端 demo, WordPress搬家教程:换空间与换域名 sympy 的 符号计算的例子 Conda 简单使用 spoolsv.exe 无法启动 太阳高度角和方位角的计算 树莓派 3 alsa 声卡驱动 PHP 7 Xdebug 深深的坑 java 线性规划 和lingo 比较 Cannot find or open the PDB file问题的解决 Python Microsoft Visual C++ Compiler Package for Python 2.7 Node debug angular 调试 js (分 karms protractor / test e2e unit ) hbase scan 的例子
CSV 文件处理成 String[] ,网银下载的文本中使用逗号分割, 使...
cndavy · 2018-01-23 · via 博客园 - cndavy

private static String[] getSplit(String txt) throws Exception { ArrayList<String> list = new ArrayList<String>(); int b=0; int begin=0; StringBuffer buff=new StringBuffer(); int iLen= txt.length(); for (int i =0 ;i<iLen;i++){ String s=txt.substring(i,i+1); switch (b){ case 0: if (s.equals("\"")){ b=1; begin=i; continue; }else throw new Exception("没有引号"); case 1: // 进入 引号中 if (s.equals("\"")) { b=2; continue; }else { buff.append(s); continue; } case 2: if (s.equals("\"")) { //字段中出现 引号 "asdfasd "" qweqwe" buff.append("\""); b=1; } else if (s.equals(",")){ b=0; list.add(buff.toString()); buff=new StringBuffer(); } } } int resultSize = list.size(); String[] result = new String[resultSize]; return list.subList(0, resultSize).toArray(result); }

posted on 2018-01-23 11:09  cndavy  阅读(190)  评论()    收藏  举报