From a240bf8124050b3f1eeb57e7c82d4c321604f1e8 Mon Sep 17 00:00:00 2001 From: kevin Date: Thu, 24 Nov 2022 17:04:44 +0100 Subject: [PATCH] probando --- .classpath | 10 ++++ .project | 17 ++++++ .settings/org.eclipse.core.resources.prefs | 2 + .settings/org.eclipse.jdt.core.prefs | 14 +++++ bin/dam/com/es/Main.class | Bin 0 -> 2392 bytes bin/dam/com/es/Persona.class | Bin 0 -> 892 bytes src/dam/com/es/Main.java | 58 +++++++++++++++++++++ src/dam/com/es/Persona.java | 32 ++++++++++++ 8 files changed, 133 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/org.eclipse.core.resources.prefs create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 bin/dam/com/es/Main.class create mode 100644 bin/dam/com/es/Persona.class create mode 100644 src/dam/com/es/Main.java create mode 100644 src/dam/com/es/Persona.java 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..c20f0ad --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + Actividad8_2 + + + + + + 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/dam/com/es/Main.class b/bin/dam/com/es/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..71c9b0f10e36f4884a88e3e01d163b57d10f0eb3 GIT binary patch literal 2392 zcmZuyOLtRM6#h>0xJkSfCWmQ+Cpbu4b}eKrM>=siaiBwghHF{BlXu##taZ=p+uz>j+xzVN_TNv>0G!7+ z3R(oVrL;^qX=TECEX9;Ck;mDQRiGp1M-F5S^w3f@wSk9!CH&ZoK z0Cb~bPbuzWRE8QpZaGn#aa6(gmk&fGeYNK6{Z<%+Mtl;#A`fi5Xww?MFGtBWf*D6pr| zXT;3r9SWmsnE(#purz;(npVuIh>VPyDL5+7QCH(?-gJzN-k`$~^h)bv0_}~?uPxiw zU758KNxwj->c3nLO%e2AP;!Lp95N^M7|G$s37k|g)Kpoq)tsYeRJ@E=SXEY@MHVaz zK>Jyyy>iD9A5IH+CT!cX12~Hj1;Y*5Z$PRzCv{Y^(l~7f(1!~uUd3xH9;%h9*7B~N z-Ug-1yJQV17!zo@8Bs7%b&z+Aba>RZwbiJRW46ZOSMWNEyPx==J;E}>#k`SD>9!9s0pE<3S+Mot?f_=d zC3)vm+`yaUUDBnJJ&`T$C_|iAaT5svKXGLefo4G}@k-{mRoucmeEnKBtDB5>V2g`2 zI%9Dcn1q3hI)pWke4||@MEkKJfpL=W2O)rcvmtm2v{yG{u9#0js zR154`UY+XcocOY}c2==!E@WB>Y9t~o)#f(6nyt3#zH&&-hUXd^cct)0E|9J@=4i<~ z(^|ID=mRk;ZzpxB8by=;EQ3;X_A6e8|3BcDIf0j7g{v?}!O?T92;WmqS`gq@9s{j- zfnT)@;MmHQA1`7XQQJ$X7VN;z644OX(#HKGf_0t%ks!u}wgxUY+7aTuU;Y zT^ZcpYv_o#br!MzvWTwXK%7AyiatT>^cs%D`-|xLS#a7H?<-_IUlD z5^9!gYnY97-W>nto+c|&32;NA{`x}end6pSjks9>BG)~^1GDC7N#Y%Tcu Ee_@h71ONa4 literal 0 HcmV?d00001 diff --git a/bin/dam/com/es/Persona.class b/bin/dam/com/es/Persona.class new file mode 100644 index 0000000000000000000000000000000000000000..724912d35242fc4f969cc1c9e0b52d2183b13d26 GIT binary patch literal 892 zcmZ{h-EI<56ouCr2By#{P)bqT+8@0EOq>U>_Qq(^gj5p@iI)dB!D(P78Kz$JnR=m# zjfodNfDdI{`^-tHp@wk&*lX=?ZGQjx`3t~nJP+V0w5ECyP0~eVmeB{3Ez?8?@D-Yu z`iqX{I+;c9$CqZ32dF5t?Q5JyLzBgN9$)M6+$dC%bTQ6&Xbo1fVV=dw?3IFVrh2NN z&RKXGCvkqJ(CMyMp7%y9ev?j34J9-}Y@(@9>h?xe&^knb4LP+#R8doC4C2IGTrI{X z`&e+a2I)l4N1ANpa*uxgIbKpVSWim0>dfR9j=tUPty8gNxhmOxfLpKw+Pt+f$;+St zHO1ZU+FZ3^dX-JgyIAHGx=Fv3Y2k#KO8l1L@xze(dpwEAy~6iRgj~0H`^5JW_eTE* z>irkD*zO~d|v=eohQY7OcXcldH#$nXe{d82`CqwGl^Y~1yZlz}f5-M$9y|!9q!L&`E5zkH@jecm_>9$_ zRNJI01i=Nhq7jEqQFRxt;=(CB#i8@M53+MZ(S4A;2SJW-yauxW&$J7WLxLRr2SjEo K6F9LQpZx{rae*}e literal 0 HcmV?d00001 diff --git a/src/dam/com/es/Main.java b/src/dam/com/es/Main.java new file mode 100644 index 0000000..064cd93 --- /dev/null +++ b/src/dam/com/es/Main.java @@ -0,0 +1,58 @@ +package dam.com.es; + +import java.io.BufferedReader; + +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 IOException, ClassNotFoundException { + + mostrarPersonas(); + } + + public static void mostrarPersonas() throws IOException, ClassNotFoundException { + File fichero = new File("C:\\\\Users\\\\kevin\\\\Documents\\\\Actividad8_1\\\\FichPersona.dat"); + FileInputStream fileinput = null; + try { + fileinput = new FileInputStream(fichero);//Creamos un FileInputStream con la ruta de "fichero" + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } + ObjectInputStream dataIS = null; + try { + dataIS = new ObjectInputStream(fileinput);//Creamos el ObjectInputStream que tendra el FileInputStream con la ruta de "fichero" + } catch (IOException ioe) { + System.out.println("Error"); + } + + String[] nombres; + int[] edades; + //Lee los datos del archivo creado en la otra actividad con el readObject() + nombres = (String[]) dataIS.readObject(); + edades = (int[]) dataIS.readObject(); + + ArrayList personas = new ArrayList<>();//Creamos la lista que tendra las personas del archivo creado en la otra actividad + + //Recorremos los datos de las personas "nombre" y "edad" y se crean y aƱaden + for (int i = 0; i < nombres.length; i++) { + personas.add(new Persona(nombres[i], edades[i])); + } + + //Se muestran las personas por pantalla + for (int i = 0; i < personas.size(); i++) { + System.out.println("Nombre: " + personas.get(i).getNombre()); + System.out.println(" Edad: " + personas.get(i).getEdad()); + System.out.println();//Como separador + + } + dataIS.close();//Cerramos el ObjectInputStream() + + } +} diff --git a/src/dam/com/es/Persona.java b/src/dam/com/es/Persona.java new file mode 100644 index 0000000..00c716d --- /dev/null +++ b/src/dam/com/es/Persona.java @@ -0,0 +1,32 @@ +package dam.com.es; + +import java.io.Serializable; + +public class Persona implements Serializable { + private String nombre; + private int edad; + public Persona(String nombre, int edad) { + this.nombre = nombre; + this.edad= edad; + } + + public Persona() { + this.nombre=null; + } + + 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; + } +} \ No newline at end of file