|
|
@ -0,0 +1,38 @@ |
|
|
|
package com.cristobalbernal.Actividad_8_2; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.FileInputStream; |
|
|
|
import java.io.FileNotFoundException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.ObjectInputStream; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
public class Main { |
|
|
|
|
|
|
|
public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException{ |
|
|
|
File fichero = new File("C:\\Users\\crist\\Documents\\2DAM\\BaseDeDatos\\Personas.dat"); |
|
|
|
FileInputStream fileInputStream = new FileInputStream(fichero); |
|
|
|
ObjectInputStream datos = new ObjectInputStream(fileInputStream); |
|
|
|
String[] nombres; |
|
|
|
String[] apellidos; |
|
|
|
int[] edades; |
|
|
|
|
|
|
|
nombres = (String[])datos.readObject(); |
|
|
|
apellidos = (String[])datos.readObject(); |
|
|
|
edades = (int[]) datos.readObject(); |
|
|
|
|
|
|
|
ArrayList<Persona> personas = new ArrayList<>(); |
|
|
|
|
|
|
|
for (int i = 0; i < nombres.length; i++) { |
|
|
|
personas.add(new Persona(nombres[i], apellidos[i], edades[i])); |
|
|
|
|
|
|
|
} |
|
|
|
for (int i = 0; i < personas.size(); i++) { |
|
|
|
System.out.println("Nombre: " + personas.get(i).getNombre()); |
|
|
|
System.out.println("Apellidos: " + personas.get(i).getApellido()); |
|
|
|
System.out.println(" Edad: " + personas.get(i).getEdades()); |
|
|
|
System.out.println(" "); |
|
|
|
} |
|
|
|
datos.close(); |
|
|
|
} |
|
|
|
} |