From c631153155660b894a270831c3af2db33e1b44eb Mon Sep 17 00:00:00 2001 From: AntonioFrische Date: Mon, 17 Oct 2022 16:57:06 +0200 Subject: [PATCH] finish --- .classpath | 10 +++++ .project | 17 ++++++++ .settings/org.eclipse.core.resources.prefs | 2 + .settings/org.eclipse.jdt.core.prefs | 14 ++++++ bin/antoniofrische/com/MainSeriable.class | Bin 0 -> 2534 bytes bin/antoniofrische/com/Persona.class | Bin 0 -> 908 bytes src/antoniofrische/com/MainSeriable.java | 48 +++++++++++++++++++++ src/antoniofrische/com/Persona.java | 27 ++++++++++++ 8 files changed, 118 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/antoniofrische/com/MainSeriable.class create mode 100644 bin/antoniofrische/com/Persona.class create mode 100644 src/antoniofrische/com/MainSeriable.java create mode 100644 src/antoniofrische/com/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..f4a0124 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + Seriable8_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/antoniofrische/com/MainSeriable.class b/bin/antoniofrische/com/MainSeriable.class new file mode 100644 index 0000000000000000000000000000000000000000..35897da677ae604ffa92cf1106c0685e86a8348e GIT binary patch literal 2534 zcmai0TUQfT7~KO&PKZ%47$GP(Zw2MjqE#ELEd;Q!flz|9sZlyi1{e)9>15)iSF5(Q z_sc)%ldF&R0lG@->RNs4YyUuhN$EZ_2__X+7mGP(=6sj^?QfqC{`}{cM*v>L_W}(H zx>VD#Ov75Tjgq#a4{6rw(3EPJ8QnJ2#ey#2Q_y@>y{--wRC9SKy?9mE90h^1hG{tG z6g2ks%`5OFth^pVBbvhSBcNb+$}sim^6H{)&&fCnA}LE#3-hWMxAM{FtQaK)J*oeJ zF~St9gr#6#@1@jZI2p$_%;gaYAvAGQ(~FK_nI(aUf)>}xu!fT9trLO03c}TcNu!_# zu}?uc5zk#L>2@hM>aj8Dv5`xg`nYXe*SiP0N5@7JiF9|yDwN$Exp7M?uj-~#%4M{b zazS4h9$pwev5=TNpUI7CnqION##P7SaZzHNv#i3x$=nRHSf)CdSDg@A&?f1MDTwxN zSCqhh1#Pu((`Bbvc38Epu7=Q#4(Z>iU{A%L<;to^h(Nc3_NuSfwtDX_9F*RN6vQ5T z*P6Idj?}f^<2#6F*pCZk)eNFffqzEN+g1?ADGSzTXxtAd5Tj<^{^Lh>V~9w$X>f&$ z5C-v_L^3S9`y>y^zWETka59YNaZ16C8@A!-RUOt5=Y1q>X@4e+7o-yXTEQw&n+it4 zI4jB8RnT>N($H3_L42ycOcl0lqb!zD^jfCiz;-IF6hVQCC5F^(iwV3Us?BhZ3c6M1 zy=kvIs$-k%Q59-BBQrg{aWa!>tuER+AqVulnwOh~OGyQa!C$UBGmffVn^KGJEfY8= zkQA6v&{_>EMUpgYq?AU705iv`79KZsHnX@W+r+!p_E<1A7B2C#cq5D~-sFX(Nb^;S z_xASHbhgr{CggBM;BvjhZj~H;HH-zk#p&Xb7Tuy_hF7T~{}F-3YDMm7^0YZtHVS#& z4kE80IPLNj?+!slo7CBI7%L!4P0PCD9V)1YR+%W$<60O6tdeB4Skz6%8`wsjwPn>I z7zu(>5Zx2(kVG(ux5Kc(UI`|bU)|xEl$pvh({=W}H~I8<((q;&w{-M4*mdP&w%SrzBOSNcGIevdmm5s$S_KRA%pyKcLOciNOT>o zQyXZ{_OIi>^ai@J1MBFC`^0ZJoNbI8&18L%-b~gXIhM%=BK?`TU;G-%Ha17oSzq(M zbk^V8n$8BA+tTqs<0a;zJ&g!v_%@HdydhDT+}}bg_0xtsh`9yNdZqAxhja8_ zVaYGyWtJME-*!(N*dw^)%C#m|7K61Us6NdTpA@fF9+ZgV< z>v>)PkHu4N+dGM_izf$(^AHAbm{<>ymmYc?W!=53w-3`e#+lfU%bWsIIww8kE^D&F zBNZl_a1o#53pZy9U*ap~O0q*=;~Q2hxjF#fCe!)I6S+zYUOZR=_s0cp?_n>#rA-6A F`xl0=ZN&fp literal 0 HcmV?d00001 diff --git a/bin/antoniofrische/com/Persona.class b/bin/antoniofrische/com/Persona.class new file mode 100644 index 0000000000000000000000000000000000000000..ac1ca524db869ce11c91cd83864578bf1726d375 GIT binary patch literal 908 zcmZ{h-)<5?7{$*l3tQ+GC{VN%wbdKIr27EY-WW}qkZOV<@p4#3It}b5%hn5@$qP-| zH0gy8;6oYD%x(&XHiY@d_nq@QAAkPd{RZ$BuRJ&c9T}x@q~ouNUWOMc2;)WYNhQlT zk{(=v`lb9PgSm`m!NIm4_oHc@=-=bpf=Qz zI=@;>RPs6FXbj^}&c~8$3N=_)$4E4v1GX_*?WNB;CqyL zZ{w1ifj#zQceiKrRYvhu5~>f{%+1dyer%?OBW5e`TZF?8!}9NPOjPbAzHh_ly2INS zz8ARH2DhjVUf*DM(7i$Pmu=YN+JMV-i)+~mRN36-%VE}rCwR&m1+0y*Cu8JTn|f|@ zV(&o3+6daL9I95yr^5~%s#e|Lu{u{5*heQ<3b>o!ii2zH{^Y@d!8ECW`dV}GzWD&% zy!n*Xj;XduR|p0dXmVaHtI*D>?!%Sxa01WpJl9$WY5rjQI!OCLkQX@I06F+?+8M|` RK{}6snAw^M99hSg{{Zf+h;je` literal 0 HcmV?d00001 diff --git a/src/antoniofrische/com/MainSeriable.java b/src/antoniofrische/com/MainSeriable.java new file mode 100644 index 0000000..433e2ef --- /dev/null +++ b/src/antoniofrische/com/MainSeriable.java @@ -0,0 +1,48 @@ +package antoniofrische.com; + +import java.io.EOFException; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +public class MainSeriable { + public static void main(String[] args) throws IOException{ + Persona persona; + File fichero = new File("C:\\Users\\AntonioFrische\\OneDrive - ABACCO Solutions\\Documents\\Schule_22_23_CFGS\\Acceso_Datos\\SpringTool_4\\Persona.dat"); + FileOutputStream fileout = new FileOutputStream(fichero); + ObjectOutputStream dataOS= new ObjectOutputStream(fileout); + String[] nombres= {"Juan","Pedro","Perico","Andrés"}; + int[] edades= {21,22,23,24}; + for (int i = 0; i < edades.length; i++) { + persona = new Persona(nombres[i],edades[i]); + dataOS.writeObject(persona); + } + dataOS.close(); + leerFichObject(fichero); + } + + public static void leerFichObject (File fichero) + throws IOException { + Persona persona; + FileInputStream filein = new FileInputStream(fichero); + ObjectInputStream dataIS = new ObjectInputStream(filein); + try { + while (true) { + persona = (Persona) dataIS.readObject(); + System.out.println("Nombre: "+persona.getNombre()+ + " Edad: "+persona.getEdad()); + } + } catch (EOFException error) { + //nada + } catch (ClassNotFoundException error) { + error.printStackTrace(); + System.out.println(error.getMessage()); + } + dataIS.close(); + + } + +} diff --git a/src/antoniofrische/com/Persona.java b/src/antoniofrische/com/Persona.java new file mode 100644 index 0000000..1da8c9a --- /dev/null +++ b/src/antoniofrische/com/Persona.java @@ -0,0 +1,27 @@ +package antoniofrische.com; + +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; + } +}