0

Well, I just started using File and I'm having a problem

My Code:

File file = new File("D:\\File\\TextFile.txt");

System.out.println(file.exists());

Output: false

even tho I've got the file on that directory!

Harout Tatarian
  • 431
  • 4
  • 14
  • 2
    You sure that the path is correct? You sure that you haven't hidden known extensions or such? – Emz Aug 12 '15 at 02:04
  • 5
    Open D:\File in command prompt and run dir. It's quite possible you have a file TextFile.txt.ext i.e. your Windows may have been configured to hide extensions. – Ravi K Thapliyal Aug 12 '15 at 02:06
  • 2
    possible duplicate of [File.exists() returns false when file exists](http://stackoverflow.com/questions/919918/file-exists-returns-false-when-file-exists) – Gary Aug 12 '15 at 02:07

1 Answers1

4

I've found the problem right after I posted. It turned out that my windows is configured to hide extensions so the correct file name would be:

D:\File\TextFile.txt.txt

Harout Tatarian
  • 431
  • 4
  • 14
  • 1
    First thing I turn off -always. Whoever thought that would be a great idea at ms should be punished. Hard! – Fildor Aug 12 '15 at 04:58