java - Split a CSV line with an specific pattern with JAVA
问题描述
I am reading a CSV file with Java. I am storing each value between commas into a String Array.
This is what prints when I read a CSV line:
Tania, Joe, Pat, , , , , , ,
When I store this line into a String Array: String [] myString = line.split(",");
I get this output when I print my string: [Tania, Joe, Pat]
And I want to get: [Tania, Joe, Pat, , , , , , ,]
I want to store the empty spaces as well.
解决方案
You should have checked Stackoverflow site, use line.split(",",-1)
.
推荐阅读
- flutter - 相关的 DropdownButtons 和引发 onChange 事件
- css - 我可以将表格列平均分开吗,类似于 flexbox 的工作方式?
- android - 搜索栏更改背景进度颜色
- angular - Angular10:在数据库中插入表单数据
- video - 如何在ffmpeg中为视频添加不透明的叠加层?
- javascript - 在烧瓶中拖放后从特定 div 获取输入值
- javascript - javascript中的自定义排序
- azure - azureml-sdk:装载数据集
- javascript - 如何从我的多选框中选择一个选项并更新我的图表?
- css - 布尔玛瓷砖不默认为水平