Philip Rego
Philip Rego

Reputation: 648

Java FileNotFoundException when reading file from command line args

In what directory does the file class look for a file? My code was working in a separate project. I have the file project2.torrent in the source directory and higher directories. I'm pretty sure it's something small. Hope I'm not being to vague.

java.io.FileNotFoundException: project2.torrent (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:146)
    at RUBTClient.parsing(RUBTClient.java:31)
    at RUBTClient.main(RUBTClient.java:17)

Upvotes: 0

Views: 554

Answers (1)

Jigar Joshi
Jigar Joshi

Reputation: 240948

In what directory does the file class look for a file?

It looks into current directory, usually from where java is launched

You can read it by

System.out.println(System.getProperty("user.dir"));

Upvotes: 1

Related Questions