0

In my game that I am making, there is a Properties file that stores the difficulty, high score etc.

What I would like to do is see if the properties file has just been created or if the section is null (if the option isn't there)

Banjo226
  • 23
  • 4
  • I don't know how to do it, so thats why I came here. There is no method that is something like properties.exists() – Banjo226 Oct 24 '15 at 03:02

1 Answers1

0

I would suggest using the java.io.File:

import java.io.*;
File f=new File("filePathName");
    if(f.exists()&&!f.isDirectory()){
        //Insert specific code
}
Josh A
  • 51
  • 6
  • 1
    Do you also know how to get the properties file location? – Banjo226 Oct 24 '15 at 03:29
  • Try using absolute path. This would be: `String filepath=f.getAbsolutePath();` That should assign the rile path including the filename to the variable filepath. – Josh A Oct 24 '15 at 15:34
  • Nono, like getting the directory of the properties file so I can use that as the file path name. – Banjo226 Oct 25 '15 at 00:34
  • I'm not sure if I understand but for example you attempt to create some file name `Filename` but you want to also find the full path location ie `C://SomeFolder//Fiename.txt` and then see if that file exists or not by using it's potential file path? If that is the case using `f.getAbsolutePath();` will return the path ie`C://SomeFolder//Fiename.txt`. But if that isn't what you want can you please clarify, thanks! – Josh A Oct 25 '15 at 14:00