小编Snk*_*ini的帖子

如何解决java.nio.file.NoSuchFileException?

我有一个名为“ result.csv”的文件,我想从该文件中读取某些数据并显示它们。我在eclipse项目文件夹中有该文件。我仍然无法读取文件。

 public static void main(String [] args) {
    int i=0;
    String filename="result.csv";
    Path pathToFile = Paths.get(filename);

    try (BufferedReader br = Files.newBufferedReader(pathToFile, StandardCharsets.US_ASCII)) { 
        // read the first line from the text file 
        String line = br.readLine(); 
        // loop until all lines are read 
        while (i<10) { 
            // use string.split to load a string array with the values from 
            // each line of 
            // the file, using a comma as the delimiter
            String[] attributes = line.split(","); 
            double x=Double.parseDouble(attributes[8]);
            double y=Double.parseDouble(attributes[9]); …
Run Code Online (Sandbox Code Playgroud)

java file

3
推荐指数
2
解决办法
3万
查看次数

标签 统计

file ×1

java ×1