Christopher Schene
asked on
How do I append to a file in java?
This code I am using creates an empty file each time and thus my file contains only 1 line all the time.
What I would like to do is append to the file if it exists or create it and append if it does not exist.
private void saveToLogFile(String s) throws FileNotFoundException {
PrintWriter pw=new PrintWriter(myLoggerFile);
pw.append(s);
pw.flush();
}
What I would like to do is append to the file if it exists or create it and append if it does not exist.
private void saveToLogFile(String s) throws FileNotFoundException {
PrintWriter pw=new PrintWriter(myLoggerFile);
pw.append(s);
pw.flush();
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
CEJH --- I am going to ask another question about Java logging --- I should have figured there would be a class for that.
Righto
ASKER