在远程向日葵中运行的
package com;
//\\2dsrt58acsspc\2DSoft\Reports\2022WW13
import java.io.BufferedReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
public class ReadCSV {
public static void main(String[] args) {
String fileName="";
List list = new ArrayList();
// 创建 reader
try (BufferedReader br = Files.newBufferedReader(Paths.get("C:\\Users\\Isliu\\Destop\\220331_2DSRT058ACS_2022WW12"))) {
// CSV文件的分隔符
String DELIMITER = ",";
// 按行读取
String line;
while ((line = br.readLine()) != null) {
// 分割
String[] columns = line.split(DELIMITER);
fileName=columns[14];
list.add(fileName);
}
} catch (IOException ex) {
ex.printStackTrace();
}
System.out.println(list.get(list.size()-2));
System.out.println(list.get(list.size()-1));
}
}
java.nio.file.NoSuchFileException: C:\Users\Isliu\Destop\220331_2DSRT058ACS_2022WW12
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:230)
at java.nio.file.Files.newByteChannel(Files.java:361)
at java.nio.file.Files.newByteChannel(Files.java:407)
at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
at java.nio.file.Files.newInputStream(Files.java:152)
at java.nio.file.Files.newBufferedReader(Files.java:2784)
at java.nio.file.Files.newBufferedReader(Files.java:2816)
at com.ReadCSV.main(ReadCSV.java:15)
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -2
at java.util.ArrayList.elementData(ArrayList.java:424)
at java.util.ArrayList.get(ArrayList.java:437)
at com.ReadCSV.main(ReadCSV.java:29)
检查过很多次文件名
输出从csv文件最后两行第十四列的内容