4 Replies Latest reply: Nov 16, 2009 7:13 AM by 807580 RSS

    need example of properties file use

      I'm writing a text based adventure game to get some practice with the Java language. The only thing that's proving to be difficult is saving the game. I need an example of a class for basic properties operations. I've found various tutorials that all have some helpful information, but putting it all together isn't working for me. Here is what I have.
      import java.io.BufferedWriter;
      import java.io.FileWriter;
      public class SaveGame{
      public static void CreateSave(String name){//create the save file
              FileWriter fstream = new FileWriter(name+".properties");
              BufferedWriter out = new BufferedWriter(fstream);
              out.write("*-=Character Information=-*");
              out.write("name= \ngender= \n");
              out.write("*-=Basic Stats=-*");
              out.write("str= \nagl= \nend= \nchr= \nitl= \nlck= \n");
              }catch(Exception e){System.err.println("Error: " + e.getMessage());}
      public static void SaveStatus/*save all variables to the file*/
      (double str, double agl, double end, double chr, double itl, 
        double lck, String name, char gender){
      // I don't know how to edit values
      public static void ReadSave(){//reads the file and sends the variable back to main class
      The big thing is, I don't know how to edit the values in the properties file. I can handle reading them but i don't know how to convert the string values to int, double, etc. Thanks in advance.