Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save washingtonsoares/e72b3c971e5b0e8aea2c to your computer and use it in GitHub Desktop.
public void salvaContatos(ArrayList<Contato> lista) {
BufferedWriter escritor = null; //objeto escritor
try {
escritor = new BufferedWriter(new FileWriter(new File("contatos")));
//Instanciação do objeto escritor
for (Contato c : lista) {
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