With a few mods most of your code works:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;
public class PropertiesProblem
{
final static String PropFN = "PropertiesProblem.ini"; //<<<<<<<<<
public static void main(String[] args) throws Exception
{
Properties prop = new Properties();
File f = new File(PropFN); //System.getProperty("user.home")+"/DogWalking/user-info/user.properties");
FileOutputStream out = null;
FileInputStream in = null;
if(!f.exists())
{ //Creates and sets defaults fine...
// new File(System.getProperty("user.home")+"/DogWalking/user-info/").mkdirs(); //Create directory
// f.createNewFile();//Create file
// in = new FileInputStream(f);
out = new FileOutputStream(f);
System.out.println("Created a new user.properties! Setting default values");
prop.setProperty("timeWalked", "0");
prop.setProperty("moneyGained", "0");
prop.store(out, "--No Comment--");
out.flush();
out.close();
in = new FileInputStream(f);
prop.load(in);
in.close();
System.out.println("created=" + prop); // {moneyGained=0, timeWalked=0}
/*
Created a new user.properties! Setting default values
created={moneyGained=0, timeWalked=0}
*/
}else if(f.exists())
{ //Finds nothing
in = new FileInputStream(f);
// out = new FileOutputStream(f); // WHat does this do???
System.out.println("Found a user.properties! Getting values!");
prop.load(in);
System.out.println("read=" + prop);
in.close();
if(prop.containsKey("timeWalked") && prop.containsKey("moneyGained"))
{
System.out.println("Success!");
}else
System.out.println("Fail! " + prop); //Every time goes here.
out = new FileOutputStream(f); // WHat does this do???
prop.store(out, "--No Comment--"); //Just Checking for debugging purposes exactly what it does... and it prints nothing!
out.flush();
out.close();
/*
Found a user.properties! Getting values!
read={moneyGained=0, timeWalked=0}
Success!
*/
}
}
}