gpt4 book ai didi

java - 线程 "main"java.io.FileNotFoundException : (The system cannot find the path specified) 中出现异常

转载 作者:行者123 更新时间:2023-12-01 23:43:12 25 4
gpt4 key购买 nike

我正在尝试在 Java Eclipse 中读取文件。系统似乎找不到该文件。

Here is my code:

  import java.util.Scanner;
import java.io.*;
public class whyDo {

public static void main(String[] args) throws IOException {


Scanner input = new Scanner(new File("c:\\Users\\Vanessa\\Downloads\\CompLet\\CompLet\\sales\\austin.txt"));

System.out.println(input);


// TODO Auto-generated method stub

}

}

When I run this code I get:

Exception in thread "main" java.io.FileNotFoundException: c:\Users\Vanessa\Downloads\CompLet\CompLet\sales\austin.txt (The system cannot find the path specified)

请帮忙。提前感谢大家。

最佳答案

由于使用了反斜杠,可以安全地假设操作系统是 Windows 的某个版本,因此大小写并不重要。我建议使用正斜杠(为了可读性),Java 可以处理它们。要读取 zip 文件,请参阅 Read Content from Files which are inside Zip file .

关于java - 线程 "main"java.io.FileNotFoundException : (The system cannot find the path specified) 中出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58250858/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com