Skip to content

Commit 9f64ea8

Browse files
committed
docs: 完善CSV工具类(csv数据正确读取)
1 parent 8e9bb18 commit 9f64ea8

File tree

1 file changed

+3
-3
lines changed
  • springboot-aop/src/main/java/com/study/module/util/office

1 file changed

+3
-3
lines changed

springboot-aop/src/main/java/com/study/module/util/office/CsvUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private static void testReadCsv() {
5757
System.out.println("读取csv文件的数据:(示例文件地址为:D:/csv-demo-1.csv)");
5858
Scanner scanner = new Scanner(System.in);
5959
String in = scanner.nextLine();
60-
if ("exit".equals(in)) {
60+
if (Arrays.asList("exit", "quit", "q").contains(in)) {
6161
break;
6262
}
6363
System.out.println("文件的数据如下:\n" + JSONObject.toJSONString(readCsv(in, true)));
@@ -144,7 +144,7 @@ public static Map<String, Object> readCsv(String csvFilePath, boolean isHasHeade
144144
List<List<String>> dataList = new ArrayList<>();
145145
while ((line = reader.readLine()) != null) {
146146
String[] parts = splitCSV(line);
147-
if (!ObjectUtils.isEmpty(parts)){
147+
if (!ObjectUtils.isEmpty(parts)) {
148148
List<String> lineData = Arrays.asList(parts);
149149
dataList.add(lineData);
150150
}
@@ -156,7 +156,7 @@ public static Map<String, Object> readCsv(String csvFilePath, boolean isHasHeade
156156
return result;
157157
}
158158

159-
public static void test() {
159+
public static void testSplitCSV() {
160160
String src1 = "\"fh,zg\",sdf,\"asfs,\",\",dsdf\",\"aadf\"\"\",\"\"\"hdfg\",\"fgh\"\"dgnh\",hgfg'dfh,\"asdfa\"\"\"\"\",\"\"\"\"\"fgjhg\",\"gfhg\"\"\"\"hb\"";
161161
try {
162162
String[] Ret = splitCSV(src1);

0 commit comments

Comments
 (0)