Skip to content

Instantly share code, notes, and snippets.

@washingtonsoares
Created January 7, 2015 17:45
Show Gist options
  • Select an option

  • Save washingtonsoares/05e4b56519efd47b4eaf to your computer and use it in GitHub Desktop.

Select an option

Save washingtonsoares/05e4b56519efd47b4eaf to your computer and use it in GitHub Desktop.
public void salvaContatos(ArrayList<Contato> lista) {
for (Contato c : lista) {
BufferedWriter escritor = null; //objeto escritor
try {
escritor = new BufferedWriter(new FileWriter(new File("contatos")));
//Instanciação do objeto escritor
escritor.write(c.toString()); //Gravação do texto
escritor.flush(); //descarga do buffer de escrita
escritor.close(); //fechamento do arquivo
} catch (IOException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment