From 6a645effdd092f39116e0c464369da26c57a27a0 Mon Sep 17 00:00:00 2001 From: yaroslav Date: Sun, 6 Nov 2022 18:10:21 +0100 Subject: [PATCH] commit --- .idea/.gitignore | 8 +++ .idea/misc.xml | 6 +++ .idea/modules.xml | 8 +++ .idea/vcs.xml | 6 +++ Serializable.iml | 11 ++++ out/production/Serializable/Main.class | Bin 0 -> 2581 bytes out/production/Serializable/Persona.class | Bin 0 -> 870 bytes src/Main.java | 58 ++++++++++++++++++++++ src/Persona.java | 24 +++++++++ 9 files changed, 121 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 Serializable.iml create mode 100644 out/production/Serializable/Main.class create mode 100644 out/production/Serializable/Persona.class create mode 100644 src/Main.java create mode 100644 src/Persona.java diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..03f397c --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..623ba0f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Serializable.iml b/Serializable.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Serializable.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/Serializable/Main.class b/out/production/Serializable/Main.class new file mode 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M1&+(ofKpzH4&}E$Bj%R$z&N9veBx)IN5yb%UzKwT?h_T~clA`Kk z81LbIfA=Ilz=zyb(bI;&W1p1^8dA44Oz}>>y0?aqdVEB+I(&>zIELu{Q~tijx15Ff L_8oq}Pl){oRWE-Y literal 0 HcmV?d00001 diff --git a/out/production/Serializable/Persona.class b/out/production/Serializable/Persona.class new file mode 100644 index 0000000000000000000000000000000000000000..703bdb00287e1eae1fcf111a1540d33e1f62bdfd GIT binary patch literal 870 zcmZ`%&2G~`5dPNj4|biTP16);ftFs9Adv@XRSpQGNKruwip0@LR_Ru$EjexveWo6Y zM1{nG2jHO)->z3pP|9U?XLi1y8TlxG55Bu?E#*)Uhex z%4sqc5d8oRfu`wIS#KzFmCV&mGM$KVKtjn-vv259S#EAA0kmiFKgiGl&C#KBZwlNwF zv#Wd}KPo*=Z1vyjX>rJHI1t!kbo3heAsoFNo<8dywi%nuzOr87S?~UU=)So}(A~dB z^_v0gFgD;adW=3o1gMd^#mYem!!DjOBY}|-=B9B zuwmF^;@EB31)kx#W$N+NZ(jF1f;(OuXq#FHsIGv$2k;*DE%=n(j_x*-E-mOk6g2H| zV|ut&+4V4-Z-*0jftQwR)kyW0pj9K=j~aP}gEb?2|7^Q7(xQ>w{}|D`)f+f8im(3y DlkRy` literal 0 HcmV?d00001 diff --git a/src/Main.java b/src/Main.java new file mode 100644 index 0000000..25126bd --- /dev/null +++ b/src/Main.java @@ -0,0 +1,58 @@ +import java.io.*; +import java.util.Scanner; + +public class Main { + public static void main(String[] args) throws IOException { + /*File file = new File("C:\\Users\\yaros\\Documents\\project\\serial.dat"); + byte[] bytes; + ByteArrayInputStream bs= new ByteArrayInputStream(bytes); // bytes es el byte[] + ObjectInputStream is = new ObjectInputStream(bs); + ClaseSerializable unObjetoSerializable = (ClaseSerializable)is.readObject(); + is.close();*/ + boolean result = false; + File file = null; + String ruta; + Scanner sc = new Scanner(System.in); + while (result == false){ + //ruta = sc.nextLine(); + file = new File("C:\\Users\\yaros\\Documents\\project\\serial.dat"); + if(file.exists()) { + FileReader fit = new FileReader(file); + BufferedReader br + = new BufferedReader(new FileReader(file)); + + // Declaring a string variable + String st; + // Condition holds true till + // there is character in a string + while ((st = br.readLine()) != null) + + // Print the string + System.out.println(st); + //leerFichObject(file); + } + else + System.out.println("The file couldnt be found"); + System.out.println("END"); + } + } + 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(); + + } +} \ No newline at end of file diff --git a/src/Persona.java b/src/Persona.java new file mode 100644 index 0000000..96b236e --- /dev/null +++ b/src/Persona.java @@ -0,0 +1,24 @@ +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