How can i write a string to a file so that the last string that was in the file stays there and the new string goes to a new line?
String line;
int[] score = new int[/* amount of scores in file */]; // all the code here is good besides for this line (I think)
BufferedReader br;
try
{
int loopCount = 0;
br = new BufferedReader(new FileReader("score.txt"));
while((line = br.readLine()) != null)
{
score[loopCount] = Integer.valueOf(line);
loopCount++;
}
br.close();
}
catch (IOException ex)
{
System.out.println(ex.getMessage());
}"Billy Bob:2550::Bobby Sue:2280::"
// count the records
String temp = line;
int recordCount = 0;
while (!"".equals(temp))
{
temp = temp.substring(temp.indexOf("::")+2);
recordCount++;
}
// parsing the data
Object[][] data = new Object[recordCount][2];
for (int i=0; i<recordCount; i++)
{
int recLen = line.indexOf("::");
String record = line.substring(0, recLen);
line = line.substring(recLen+2);
int nameLen = record.indexOf(":");
data[i][0] = record.substring(0, nameLen);
data[i][1] = Integer.valueOf(record.substring(namLen+1));
}String name = (String)data[n][0]; int score = (Integer)data[n][1];
String name = (String)data[n][0]; int score = (Integer)data[n][1];
String record = line.substring(0, recLen);
String name = (String)data[n][0]; int score = (Integer)data[n][1];
String record = line.substring(0, recLen);