Last active
August 29, 2015 14:15
-
-
Save JuanjoSalvador/42448414a42034b3dcda to your computer and use it in GitHub Desktop.
Escribe objetos en un fichero con Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
public class ObjectWriter { | |
public static void añadirContacto() { | |
Objeto nuevoObjeto = new Objeto(parametro_1, parametro_2, parametro_3); | |
try { | |
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("/home/USUARIO/registro.txt", true)); | |
oos.writeObject(nuevoObjeto); | |
oos.close(); | |
System.out.println("Objeto escrito correctamente"); | |
} catch (IOException ex) { | |
System.out.println("Ocurrió un error IO."); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment