commit c95e5202e3b8adbee149df6833ae518cb318c2d9 Author: Cristobal Date: Sun Nov 20 18:52:30 2022 +0100 Commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..ffb0d25 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + Proyecto_8_1 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/bin/com/cristobalbernal/Proyecto_8_1/Main.class b/bin/com/cristobalbernal/Proyecto_8_1/Main.class new file mode 100644 index 0000000..da9f097 Binary files /dev/null and b/bin/com/cristobalbernal/Proyecto_8_1/Main.class differ diff --git a/bin/com/cristobalbernal/Proyecto_8_1/Persona.class b/bin/com/cristobalbernal/Proyecto_8_1/Persona.class new file mode 100644 index 0000000..aa4c11f Binary files /dev/null and b/bin/com/cristobalbernal/Proyecto_8_1/Persona.class differ diff --git a/bin/com/cristobalbernal/Proyecto_8_1/package-info.class b/bin/com/cristobalbernal/Proyecto_8_1/package-info.class new file mode 100644 index 0000000..b41ab12 Binary files /dev/null and b/bin/com/cristobalbernal/Proyecto_8_1/package-info.class differ diff --git a/bin/module-info.class b/bin/module-info.class new file mode 100644 index 0000000..1c9df33 Binary files /dev/null and b/bin/module-info.class differ diff --git a/src/com/cristobalbernal/Proyecto_8_1/Main.java b/src/com/cristobalbernal/Proyecto_8_1/Main.java new file mode 100644 index 0000000..5aba312 --- /dev/null +++ b/src/com/cristobalbernal/Proyecto_8_1/Main.java @@ -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 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"); + } + +} diff --git a/src/com/cristobalbernal/Proyecto_8_1/Persona.java b/src/com/cristobalbernal/Proyecto_8_1/Persona.java new file mode 100644 index 0000000..666139a --- /dev/null +++ b/src/com/cristobalbernal/Proyecto_8_1/Persona.java @@ -0,0 +1,42 @@ +package com.cristobalbernal.Proyecto_8_1; + +import java.io.Serializable; + +public class Persona implements Serializable{ + private String nombre; + private String apellido; + private int edad; + + public Persona(String nombre,String apellido, int edad) { + this.nombre = nombre; + this.apellido = apellido; + this.edad= edad; + } + + public Persona() { + this.nombre=null; + } + public String getApellido() { + return apellido; + } + public void setApellido(String apellido) { + this.apellido = apellido; + } + + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public int getEdad() { + return edad; + } + + public void setEdad(int edad) { + this.edad = edad; + } +} diff --git a/src/com/cristobalbernal/Proyecto_8_1/package-info.java b/src/com/cristobalbernal/Proyecto_8_1/package-info.java new file mode 100644 index 0000000..e6edce8 --- /dev/null +++ b/src/com/cristobalbernal/Proyecto_8_1/package-info.java @@ -0,0 +1 @@ +package com.cristobalbernal.Proyecto_8_1; \ No newline at end of file diff --git a/src/module-info.java b/src/module-info.java new file mode 100644 index 0000000..690e810 --- /dev/null +++ b/src/module-info.java @@ -0,0 +1,9 @@ +/** + * + */ +/** + * @author crist + * + */ +module Proyecto_8_1 { +} \ No newline at end of file