
package com.company.project.utils;
import java.io.*;
import java.util.Map;
public class ReadCsv {
public static void main(String[] args) {
String csvFile = "E:\data\CSV_20211229153432.csv";
BufferedReader br = null;
String line = "";
String cvsSplitBy = ","; //csv每行数据的间隔方式,这里是逗号,有的是| 竖线
Map row1;
int i = 0;
try {
// in = new BufferedReader(new FileReader(csvFile));
DataInputStream in = new DataInputStream(new FileInputStream(new File(csvFile)));
br = new BufferedReader(new InputStreamReader(in, "GBK"));
while ((line = br.readLine()) != null) {
// user中:位置名称,经度,纬度,区域(城市、农村)
String[] country = line.split(cvsSplitBy);
for (int j = 0; j < country.length; j++) {
System.out.print(country[j]+"=");
}
System.out.println();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)