|
|
@ -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(); |
|
|
|
|
|
|
|
} |
|
|
|
} |