我是编程新手,我遇到了以下要求。我需要使用java拆分下面的内容。 csv文件中有多行这样的行
INPUT: "EmpID","User ID","First Name","Location","Last Name","JobCode"
将上述内容保存到数组并显示输出如下
OUTPUT: First Name_Last Name : "EmpID","User ID","First Name","Location","Last Name","JobCode"
这是我的代码:
while ((line = reader.readLine()) != null) {
String[] parts = line.split(",", 4);
if (parts.length >= 4) {
String key = parts[2] + "_" + parts[4];
map.put(key, line);
}
}
在这种情况下如何使用拆分?