Como Hacer Fichero.dat

2
* ****************************************************************************** ******************************************  A) REALIZA UN PROGRAMA JAVA QUE CREE UN FICHERO BINARIO PARA GUARDAR DAT OS (OBJETOS) DE DEPARTAMENTOS (departamentos.dat)  ************************************************************************ ************************************************ */  try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStre a m(departamentos.dat))) { oos.writeObject(new Dpto(1, "Recursos Humanos", "Sevilla"));  oos.writeObject(new Dpto(2, "Gestión", "Cádiz")); oos.writeObject(new Dpto(3, "Post Venta", "Ubrique")); oos.writeObject(new Dpto(4, "Logística", "Murcia")); oos.writeObject(new Dpto(5, "Atención al Cliente", "Madrid")); oos.close(); } catch (IOException ex) {  System.out.println("ER ROR: Imposible de generar \"departamentos.dat\ "");  }

Transcript of Como Hacer Fichero.dat

* ************************************************************************************************************************ A) REALIZA UN PROGRAMA JAVA QUE CREE UN FICHERO BINARIO PARA GUARDAR DATOS (OBJETOS) DE DEPARTAMENTOS (departamentos.dat) ************************************************************************************************************************ */ try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(departamentos.dat))) { oos.writeObject(new Dpto(1, "Recursos Humanos", "Sevilla")); oos.writeObject(new Dpto(2, "Gestin", "Cdiz")); oos.writeObject(new Dpto(3, "Post Venta", "Ubrique")); oos.writeObject(new Dpto(4, "Logstica", "Murcia")); oos.writeObject(new Dpto(5, "Atencin al Cliente", "Madrid")); oos.close(); } catch (IOException ex) { System.out.println("ERROR: Imposible de generar \"departamentos.dat\""); }