@ -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 |
@ -0,0 +1,6 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<project version="4"> | |||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="19" project-jdk-type="JavaSDK"> | |||||
<output url="file://$PROJECT_DIR$/out" /> | |||||
</component> | |||||
</project> |
@ -0,0 +1,8 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<project version="4"> | |||||
<component name="ProjectModuleManager"> | |||||
<modules> | |||||
<module fileurl="file://$PROJECT_DIR$/Serializable.iml" filepath="$PROJECT_DIR$/Serializable.iml" /> | |||||
</modules> | |||||
</component> | |||||
</project> |
@ -0,0 +1,6 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<project version="4"> | |||||
<component name="VcsDirectoryMappings"> | |||||
<mapping directory="$PROJECT_DIR$" vcs="Git" /> | |||||
</component> | |||||
</project> |
@ -0,0 +1,11 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<module type="JAVA_MODULE" version="4"> | |||||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | |||||
<exclude-output /> | |||||
<content url="file://$MODULE_DIR$"> | |||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | |||||
</content> | |||||
<orderEntry type="inheritedJdk" /> | |||||
<orderEntry type="sourceFolder" forTests="false" /> | |||||
</component> | |||||
</module> |
@ -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(); | |||||
} | |||||
} |
@ -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; | |||||
} | |||||
} |