0

Im trying to read a file in Java Eclipse. The system cant seem to find the file.

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)

Please help. Thanks to everybody in advance.

  • Where is your file on your system? Did you typed 'CompLet' twice by mistake? – beatrice Oct 05 '19 at 17:49
  • Its one zip folder called compLet, and then its a regular folder called CompLet, thats the reason why it's two CompLets, I even put the file in the source folder of the project, eclipse lets me drag it over. The system cant find it – Joshua Matthews Oct 05 '19 at 17:57
  • your local disk C is lower case. doubt it has lower case name – George Weekson Oct 05 '19 at 18:00

1 Answers1

0

As backslashes are used, it is safe to assume that the operation system is some version of Windows, so case does not matter. I suggest using forward slashes (for readability), Java can handle them. To read a zip file, see Read Content from Files which are inside Zip file.

Jonathan Rosenne
  • 2,159
  • 17
  • 27