java open file for writing overwrite code example Example: java write in a file without overwriting PrintWriter pw = new PrintWriter(new FileWriter(file, true))