Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
目前,当我逐行导入 CSV 文件时,String.split(",")如果有一行看起来像"foo,,bar,,fizz,,,"该方法返回一个长度为 5 的数组,看起来像["foo", "", "bar, "", "fizz"]. 如何获得返回长度为 8 的数组的方法["foo", "", "bar", "", "fizz, "", "", ""]?
String.split(",")
"foo,,bar,,fizz,,,"
["foo", "", "bar, "", "fizz"]
["foo", "", "bar", "", "fizz, "", "", ""]
还有另一个重载split可以实现:
split
string.split(",", -1);