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

推荐订阅源

爱范儿
爱范儿
腾讯CDC
博客园 - 司徒正美
A
About on SuperTechFans
H
Help Net Security
J
Java Code Geeks
C
Check Point Blog
B
Blog RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
MongoDB | Blog
MongoDB | Blog
U
Unit 42
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
MyScale Blog
MyScale Blog
V
Visual Studio Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
I
InfoQ
H
Hackread – Cybersecurity News, Data Breaches, AI and More
F
Fortinet All Blogs
博客园 - 聂微东
酷 壳 – CoolShell
酷 壳 – CoolShell
GbyAI
GbyAI
博客园 - 【当耐特】
雷峰网
雷峰网

博客园 - 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)  评论()    收藏  举报