嗨我有一个csv叫做test.csv。我试图逐行读取csv并将值转换为哈希键值对。这是代码-
public class Example {
public static void main(String[] args) throws ParseException, IOException {
// TODO Auto-generated method stub
BufferedReader br new BufferedReader(new FileReader("test.csv"));
String line null;
HashMap map new HashMap();
while((linebr.readLine())!null){
String str[] line.split(",");
for(int i0;i
String arr[] str[i].split(":");
map.put(arr[0], arr[1]);
}
}
System.out.println(map);
}
}
csv文件如下-
1,"testCaseName":"ACLTest","group":"All_Int","projectType":"GEN","vtName":"NEW_VT","status":"ACTIVE","canOrder":"Yes","expectedResult":"duplicateacltrue"
2,"testCaseName":"DCLAddTest","group":"India_Int","projectType":"GEN_NEW","vtName":"OLD_VT","status":"ACTIVE","canOrder":"Yes","expectedResult":"invalidfeaturesacltrue"
当我运行此代码时出现此错误-
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
Example.main(Example.java:33)
谁能帮助我修复代码并找出程序中的错误
【感谢龙石为本站提供数据共享交换平台 http://www.longshidata.com/pages/exchange.html】