Gravar uma lista em um arquivo

Olá, estou precisando de uma ajuda para saber o porquê de meu arquivo txt só estar com o último elemento da lista. Com o debug percebi que a cada passo do meu loop o arquivo “reseta”, porém não sei como corrigir isso.

Segue o método:

public void SalvarDados() throws IOException, ClassCastException {
BufferedWriter bw = null;
File eleitor = new File(“C:\Eleicao\eleitores.txt”);
File candidato = new File(“C:\Eleicao\candidatos.txt”);
String ToString = null;
try {
for (Pessoa x : this.listaPessoas) {
try {
ToString = ((Eleitor) x).salvaString();

				if (!eleitor.exists())
					eleitor.createNewFile();

				bw = new BufferedWriter(new FileWriter(eleitor.getAbsolutePath()));

				System.out.println("Documento Salvo.");
			} catch (ClassCastException f) {
				ToString = ((Candidato) x).salvaString();

				if (!candidato.exists())
					candidato.createNewFile();

				bw = new BufferedWriter(new FileWriter(candidato.getAbsolutePath()));

				System.out.println("Documento Salvo.");
			}finally {
				bw.write(ToString+"\n");
			}

		}
	} catch (IOException e) {
		e.printStackTrace();
	} finally {
		bw.close();
	}

	File partido = new File("C:\\Eleicao\\partidos.txt");
	for (Partido x : this.listaPartidos) {
		// BufferedWriter bw = null;
		try {
			String PartidoToString = x.salvaString();

			if (!partido.exists())
				partido.createNewFile();

			FileWriter fw = new FileWriter(partido.getAbsolutePath());
			bw = new BufferedWriter(fw);
			bw.write(PartidoToString);
			bw.newLine();

			System.out.println("Documento Salvo.");
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			bw.close();
		}
	}
}

Bom dia,
o problema é o seguinte:

o write vai grava sobre tudo, troca por append

Troquei porém a situação continua. Tem alguma coisa de diferente nesse código que não consigo identificar.

Nops, com append temq funcionar. Tirou TODOS write?

public void SalvarDados() throws IOException, ClassCastException {
BufferedWriter bw = null;
File eleitor = new File(“C:\Eleicao\eleitores.txt”);
File candidato = new File(“C:\Eleicao\candidatos.txt”);
String ToString = null;
try {
for (Pessoa x : this.listaPessoas) {
try {
ToString = ((Eleitor) x).salvaString();

				if (!eleitor.exists())
					eleitor.createNewFile();

				bw = new BufferedWriter(new FileWriter(eleitor.getAbsolutePath()));

				System.out.println("Documento Salvo.");
			} catch (ClassCastException f) {
				ToString = ((Candidato) x).salvaString();

				if (!candidato.exists())
					candidato.createNewFile();

				bw = new BufferedWriter(new FileWriter(candidato.getAbsolutePath()));

				System.out.println("Documento Salvo.");
			}finally {
				bw.append(ToString+"\n");
			}

		}
	} catch (IOException e) {
		e.printStackTrace();
	} finally {
		bw.close();
	}

	File partido = new File("C:\\Eleicao\\partidos.txt");
	for (Partido x : this.listaPartidos) {
		try {
			String PartidoToString = x.salvaString();

			if (!partido.exists())
				partido.createNewFile();

			FileWriter fw = new FileWriter(partido.getAbsolutePath());
			bw = new BufferedWriter(fw);
			bw.append(PartidoToString);
			bw.newLine();

			System.out.println("Documento Salvo.");
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			bw.close();
		}
	}

Ficou assim, porém o mesmo resultado
}

Bom dia,

Tente isso:

bw = new BufferedWriter(new FileWriter(partido.getAbsolutePath(), true));