I've been working on a server for my hobby game and I'm finally ready to implement loading/saving, I was planning on doing a tutorial series for the server/client (creating an multiplayer 2d game) so I wanted to do the player loader/saving through text files, so I didn't have to have SQL and JDBC tutorials on the side.
When creating the account, this is what is saved to the text file
writer.println("// Account Name");
writer.println("[Username] = " + username);
writer.println("[Password] = " + password);
writer.println("// Player Data");
writer.println("[PlayerX] = 0.0");
writer.println("[PlayerY] = 0.0");
However, I wanted to skip the line that stored the password while storing, so I can dispose of the password value at login.
So, in my save code, as you can see I have this
Misc.log("Saving Character File for user: " + username);
writer = new PrintWriter(accountDir + username+".txt", "UTF-8");
writer.println("// Account Name");
writer.println("[Username] = " + username);
writer.println("// Player Data");
writer.println("[PlayerX] = " + p.getX());
writer.println("[PlayerY] = " + p.getY());
writer.close();
Now, Obviously, Deleting that line of code isn't going to do anything for me, but I can't really figure out how I should go about "skipping" that line, I thought about using a BufferedReader to Read each line before writing, then returning if the line started with "[Password]" however, that would be really inneficient, I would think.
What would you guys recommend for this? Could you write it out in Psuedo (or just regular...?) code for me so I can finish this off.