我正在用Apache和CSVRecord中的CSVFormat解析一个csv文件: CSVRecord [comment=null,mapping={Id=0,FirstName=1,LastName=2},recordNumber=1,values=1,John,韦恩]
我只需要提取前1,约翰,韦恩的值。
使用以下选项获得结果。
String[] split = record.split("values=\\[");
String result = split[1].substring(0, split[1].length() - 2);我的问题是:在Java中有比这更好的选择(更快)吗?
发布于 2019-05-29 15:37:31
试试这个:
String txt = "CSVRecord [comment=null, mapping={Id=0, FirstName=1, LastName=2}, recordNumber=1, values=[1, John, Wayne]]";
String[] sub = txt.substring(txt.indexOf("values=[")).split("[\\[\\]]");
System.out.println(sub[1]);https://stackoverflow.com/questions/56364012
复制相似问题