public class DemoT {
public static void main(String[] args) throws Exception {
ClassPathResource resource = new ClassPathResource("20200916_order_detail.csv");
String path = resource.getPath();
InputStream in = resource.getInputStream();
byte[] b = new byte[2048];
int c = 0;
String str = "";
while((c = in.read(b)) != -1){
str += new String(b,0,c);//在此拼接
}
String[] s = str.split("\n");//以\n来截取!转化为数组!
System.out.println(s.length);
System.out.println(s[1]);
System.out.println(s[2]);
}
}
如果是文件是其他路径下的