The try block won't cause the overwrite. Its the print that's doing that. Close shouldn't throw an error in the PrintWriter; only the constructor is mandated to do that.
Move all file handling into a try block. Use only a member to declare the path to it; File() may throw an error as well. Switch it to the FileWriter class as this makes appending easier:
PHP Code:
BufferedWriter writer = null;
try
{
File myFile = new File(FILEPATH);
// here you can force a new file creation if myFile.exists is false.
FiileWriter fp = new FileWriter(myFile, true);
writer = new BufferedWriter(fp);
writer.write("Appended data");
writer.newline();
}
catch (Exception ex)
{
// split up as you see fit.
}
finally
{
try
{
writer.close();
}
catch (Exception ex)
{
}
}
Try that.