Leggere un file
import java.io.*;
public class testLetturaFile {
public static void main(String[] args) {
try{
ObjectInputStream in = new ObjectInputStream(new FileInputStream("c:\\punti.dat"));
Punto p;
while ((p = (Punto) in.readObject() )!= null){
System.out.println(p.x + " " + p.y);
}
/*
* in alternativa:
* Punto p;
* p = (Punto) in.readObject();
* while (p!= null){
* :
* p = (Punto) in.readObject();
* }
*/
}
catch(Exception e){
}
}
}