代码如下:
@Test
public void TESTt() {
File csv = new File("D:\\2021-04.csv");
//File csv = new File("D:\\cs.csv");
csv.setReadable(true);
csv.setWritable(true);
InputStreamReader isr = null;
try {
try {
isr = new InputStreamReader(new FileInputStream(csv), "UTF-8");
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
BufferedReader br = new BufferedReader(isr);
String line = "";
ArrayList<String> records = new ArrayList<>();
//csv表格读取行数
while (true) {
try {
if (!((line = br.readLine()) != null)) break;
} catch (IOException e) {
throw new RuntimeException(e);
}
records.add(line);
}
System.out.println(line);
System.out.println("csv表格读取行数:" + records.size());
}
乱码如下:
急,有做过的老板吗?解答一下,怎么写,源码可以直接复制运行