|
|
@ -0,0 +1,31 @@ |
|
|
|
package com.cristobalbernal.Proyecto_8_1; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.ObjectOutputStream; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
public class Main { |
|
|
|
public static void main(String[] args)throws IOException { |
|
|
|
File fichero = new File("C:\\Users\\crist\\Documents\\2DAM\\BaseDeDatos\\Personas.dat"); |
|
|
|
FileOutputStream fos = new FileOutputStream(fichero); |
|
|
|
ObjectOutputStream oos = new ObjectOutputStream(fos); |
|
|
|
ArrayList<Persona> personas = new ArrayList<>(); |
|
|
|
|
|
|
|
String[] nombres= {"Antonio","Perico","JuanJo","Joan"}; |
|
|
|
String[] apellidos = {"Pere","Caldero","Persiana","Martinez"}; |
|
|
|
int[] edades= {20,18,19,45}; |
|
|
|
|
|
|
|
oos.writeObject(nombres); |
|
|
|
oos.writeObject(apellidos); |
|
|
|
oos.writeObject(edades); |
|
|
|
|
|
|
|
|
|
|
|
fos.close(); |
|
|
|
oos.close(); |
|
|
|
|
|
|
|
System.out.println("Se han creado los datos y guardado en el archivo correspondiente"); |
|
|
|
} |
|
|
|
|
|
|
|
} |