I have a code that should write lines in File.. - If file don't exist, it should make new file with that name. - If file exist, it should just write new line...
It appears that it always make new file and i cant figure out how to avoid it... Here is my code...
How to make it just to write new line if file is already there?
Thx for ur time...
if (isANumber(value) == true) {
String valResult = "validation_result=VALID";
BufferedWriter writer = null;
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("ValidationResults.txt")));
System.out.println("Writing in TEXT file: " + "type=" + key + ";value=" + value + ";" + valResult);
writer.newLine();
writer.write("\ntype=" + key + ";value=" + value + valResult + "\n");
writer.flush();
writer.close();
} else {
valResult = "validation_result=INVALID";
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("ValidationResults.txt")));
System.out.println("Writing in TEXT file: " + "type=" + key + ";value=" + value + ";" + valResult);
writer.newLine();
writer.write("\ntype=" + key + ";value=" + value + ";" + valResult + "\n");
writer.flush();
writer.close();
}