How do i adjust the following code so that it will load the existing strings from file.txt and continue to add them in the same file without clearing the file on re-start?
ArrayList<String> ar = new ArrayList<String>();
void draw(){
}
void keyPressed() {
if ((key=='1')) {
String s1 ="Pressed one";
ar.add(s1);
}
if ((key=='2')) {
String s2 ="Pressed two";
ar.add(s2);
}
if ((key == ENTER)) {
String[] stringArray = ar.toArray(new String[0]);
saveStrings("file.txt", stringArray);
printArray(stringArray);
}
}