Erreur : java.util.NoSuchElementException
Bonjour,
Je suis débutant en Java et j'ai une erreur de compilation depuis ce matin que je n'arrive pas à résoudre.
Le compilateur m'indique l'erreur suivante :
Citation:
Exception in thread "main" java.util.NoSuchElementException
at java.util.StringTokenizer.nextToken(Unknown Source)
at aeroport.Avion.genererAvions(Avion.java:29)
at aeroport.Gestion.main(Gestion.java:16)
Voici le code de l'application :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| public static void genererAvions()throws IOException{
BufferedReader entree=new BufferedReader(new FileReader("C:\\Users\\pc\\Desktop\\Planning\\DonneesProjet\\avions11-v1.txt"));
String e,id,type;
int nbPlaces;
while(entree.ready()){
e=entree.readLine();
StringTokenizer st=new StringTokenizer(e," ");
id=st.nextToken();
type=st.nextToken();
nbPlaces=Integer.parseInt(st.nextToken());
new Avion(id,type,nbPlaces);
}
} |
L'erreur se situe au id=st.nextToken();
Voici le code de gestion.main
Code:
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
| public static void main(String[] args) {
try{
AgentMT.genererAgentMTs();
AgentTP.genererAgentTPs();
Depart.genererDeparts();
Arrivee.genererArrivees();
Avion.genererAvions();
Vol.genererToutesTaches();
//Tache.afficherTaches();
AgentTP.affecterRepas();
TacheVol.affecterToutesTachesDeVol();
Agent.toutAfficher();
Tache.afficherNonAffectees();/*
while(Tache.tachesNonAffectes()){
Tache.affecterTachesNonAffectees();
TacheVol.affecterToutesTachesDeVol();
Tache.afficherNonAffectees();
}*/
}
catch(IOException e){
System.out.println(e.toString());
}
} |
Pouvez-vous m'aider?
Merci beaucoup