This discussion is archived
4 Replies Latest reply: Nov 29, 2006 1:02 PM by 807607 RSS

FileReader and StringTokenizer

807607 Newbie
Currently Being Moderated
what I'm trying to do is to read String and Double date in a txt document here my code:
import java.io.*;
import java.util.*;
public class partie1 {
     static final int limite_colones=10;
     static final int limite_lignes=10;
     static final int limite_matieres=5;
     static final int limite_eleves=15;
     static final String titre="�cole secondaire Cartierville";
     static String nomEleve[]=new String[limite_eleves];
     static double notesEleve[][]=new double[limite_eleves][limite_matieres];
     
     public static void main(String[] args)throws IOException {
          String ligne,ficEleve="c:/ficEleves.txt";
          BufferedReader ficnomlogique=new BufferedReader(new FileReader(new File(ficEleve)));
          while ((ligne=ficnomlogique.readLine())!=null){
               StringTokenizer ligneTemp=new StringTokenizer (ligne,":");
               for(int i=0;i<15;i++){
                    nomEleve=ligneTemp.nextToken();
                    System.out.println(nomEleve[i]);
                    for(int j=0;j<5;j++){
                         notesEleve[i][j]=Double.parseDouble(ligneTemp.nextToken());
                         System.out.println(notesEleve[i][j]);
                    }     
               }
          }
     }
}
and this is what they give me as error message:

Alain
100.0
90.0
88.0
60.0
65.0
Exception in thread "main" java.util.NoSuchElementException
at java.util.StringTokenizer.nextToken(Unknow Source)
at partiel.main(partie1.java:20)

so i understand that it doesnt change ligne or doesnt do the for correctly but i can't figure where is my mistake.

thank for your help