1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| /**
* @(#)Lire.java
*
*
* @author
* @version 1.00 2008/4/20
*/
import java.io.*;
import java.util.*;
public class Lire {
public static void main(String arg[]) {
personne p=null;
//ouverture du fichier
BufferedReader IN= null;
try{
IN= new BufferedReader (new FileReader("out"));
}
catch(Exception e){
Erreur(e,1);
}
//données
String ligne=null;
String[] champs=null;
String prenom=null;
String nom=null;
int age=0;
//Gestion des eventuelles erreurs
try{
while(IN.readLine()!=null){
champ=ligne.split(",");
prenom=champ[0];
nom=champ[1];
age=Interger.ParseInt(champ[2]);
System.out.println(""+new personne(prenom,nom,age));
}
catch(Exception e){
Erreur(e,2);
}
//Fermeture du fichier
try{
IN.close();
}
catch(Exception e){
Erreur(e,3);
}
}
}
public static void Erreur(Exception e,int code){
System.err.println("Erreur: "+e);
System.exit(code);
}
} |