Thread: Hangman Game
View Single Post
  #8 (permalink)  
Old 07-03-2008, 02:28 PM
L23 L23 is offline
Member
 
Join Date: Jul 2008
Posts: 5
L23 is on a distinguished road
I need to update a players Information. I am able to change the players information by the following method:

public String updatePlayerInfo(int playerNr,int correct,int gamesPlayed)throws FileNotFoundException,IOException
{
String playerInfo="";
FileReader fr=new FileReader(myFile);
BufferedReader br=new BufferedReader(fr);
String line=br.readLine();
while(line!=null)
{


StringTokenizer st=new StringTokenizer(line);
String num=st.nextToken();
int playerNum=Integer.parseInt(num);
String name=st.nextToken();
String score=st.nextToken();
int correctGames=Integer.parseInt(score);
String play=st.nextToken();
int played=Integer.parseInt(play);


if(playerNum==playerNr)
{


correctGames=correct;
played=gamesPlayed;

playerInfo=playerInfo+playerNum+" "+name+" "+correctGames+" "+played;
playerInfo=playerInfo+"\n";


}
line=br.readLine();
}
return playerInfo;
}

I am having trouble updating the text file with the new information
Reply With Quote