Hi, I'm new here at Tigsource, I really don't know if this is the place to be asking about this but here is my dilemma.
I am creating a small little game in Java to help me learn more about programming, and by little I mean LITTLE, text based sort of thing, really simple. It's a game called Sword Game, and my only issue so far is writing to a simple text file. I have a file called playerCfg.cfg, and I have created a method for reading the values in the file with a scanner. Basically, everything is in one line, with a word to indicate the type of info that the game needs, like level or gold, and then a number next to it to indicate the value.
So, I use something likeThis is the method for setting it (so far)
public static void setPlayerNumbersCFG(int type, int amount)throws IOException
{
//the scanner crap is copy pasted from the readPlayerNumbersCFG() to save time writing more code
Scanner cfgPlayerNumScan = new Scanner(new File("playerConfig.cfg"));
if(type == 0)
{
//again, the contents of this if() are copy pasted from the reading method
cfgPlayerNumScan.findInLine("level ");
cfgPlayerNumScan.nextInt();
}
//there's more code here..........
}
Now with the method for writing each value I need to find "level" and then change the number next to it to something else. I have looked all over google and all the tutorials are very confusing, and they all seem to give examples for more complex operations than reading from a simple text file. If anybody could give me a simple snippet of code explaining what I would have to do that would be awesome.
EDIT: I put in my actual code and changed my wording a little bit to make it more clear.