0

Although file(deneme.txt) is in the same src file with runner class. Why cannot I use just file name?

import java.io.File;

public class Runner {
    public static void main(String []args) {
        //File file = new File("deneme.txt");
        File file = new File("C:\\Users\\serha\\eclipse-workspace\\HW1\\src\\deneme.txt");
        System.out.println(file.exists());
        System.out.println(file.isFile());
    }
}
  • 2
    Does this answer your question? [Java says FileNotFoundException but file exists](https://stackoverflow.com/questions/19307622/java-says-filenotfoundexception-but-file-exists) – Johannes Kuhn Mar 19 '22 at 09:54
  • You will want to learn what a [current working directory](https://en.wikipedia.org/wiki/Working_directory) is. – VGR Mar 19 '22 at 15:51

0 Answers0