线程“ main”中的异常java.io.FileNotFoundException :(系统找不到指定的路径)

问题描述 投票:0回答:1

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

这是我的代码:

  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

}

}

运行此代码时,我得到:

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

请帮助。预先感谢大家。

java eclipse exception java-io filenotfoundexception
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.