1

New coder here & I've come to a halt in a program because I cannot get Java to recognize a file. I've created a File object

    //Create File objects for IP and OP files
    java.io.File fileIP = new java.io.File("RedeptionLabIP");
    java.io.File fileOP = new java.io.File("RedeptionLabOP");

    //Debug Code
    System.out.println(fileIP.getAbsolutePath());
    System.out.println(fileIP.getName());
    System.out.println(fileIP.isDirectory());
    System.out.println(fileIP.isFile());
    System.out.println(fileIP.exists());

Returns

C:\Users\GCooke\Desktop\CSC - Intro to Programmig JAVA\RedemptionLab\RedeptionLabIP RedeptionLabIP

false

false

false

(the typo in Programming is not the issue, thats what i named my folder by accident D:)

any suggestions would help!

Levi Moreira
  • 11,917
  • 4
  • 32
  • 46
P Cooke
  • 11
  • 2
  • 1
    See this SO post: [Check if file exists without creating it](https://stackoverflow.com/questions/11291785/check-if-file-exists-without-creating-it). From the accepted answer: _When you instantiate a File, **you're not creating anything on disk** but just building an object on which you can call some methods, like exists()_. – skomisa May 17 '18 at 16:14
  • Well is that the directory where the file is? You didn't really give much context to what your issue is. – RobOhRob May 17 '18 at 16:18
  • 1
    Possible duplicate of [File Not Created in Java](https://stackoverflow.com/questions/11944415/file-not-created-in-java) – vkx May 17 '18 at 19:37

0 Answers0