en effet c'est bien dans cette classe java.io.file qui faut que je pioche...
j'ai trouvé ce site qui donne pas mal d'aide.
Néanmoins, je ne vois pas comment faire... 
A un moment dans le main, j'ai cette instruction :
Championnat ch = new Championnat("test.txt");
qui fait donc référence à ceci dans la classe Championnat :
1 2 3 4 5 6 7 8
| /** procedure qui participe a la sauvegarde */
public Championnat(String fich) {
cl = new Classement();
cl.lireFichier(fich);
nbrMaxEq = cl.getNbrMaxEq();
gm = new Graphe_Matrice(nbrMaxEq);
gl = new Graphe_ListeAdj(nbrMaxEq);
} |
où cl est définit comme tel :
et cl.lirefichier dans la classe Classement le voici :
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 68 69
| /** Lecture du fichier avec les informations */
public void lireFichier(String nomFich) {
String line;
int i = 0;
boolean firstLine = true;
try {
FileReader fich = new FileReader(nomFich);
BufferedReader tampon = new BufferedReader(fich);
boolean eof = false;
while (!eof) {
line = tampon.readLine();
if (line == null)
eof = true;
else {
if (firstLine) {
int nbrEq = Integer.parseInt(line);
eq = new Equipe[nbrEq];
ind = 0;
nbrMaxEq = nbrEq;
firstLine = false;
} else {
line = line.trim();
ind = line.indexOf(' '); // indice de l'espace
String nom = line.substring(0, ind);// on recupere le nom
line = line.substring(ind);
line = line.trim();
ind = line.indexOf(' '); // espace
int Pts = Integer.parseInt(line.substring(0, ind)); // on recupere les points
ind = line.indexOf(' ');
line = line.substring(ind);
line = line.trim();
ind = line.indexOf(' ');
int J = Integer.parseInt(line.substring(0, ind));
ind = line.indexOf(' ');
line = line.substring(ind);
line = line.trim();
ind = line.indexOf(' ');
int G = Integer.parseInt(line.substring(0, ind));
ind = line.indexOf(' ');
line = line.substring(ind);
line = line.trim();
ind = line.indexOf(' ');
int N = Integer.parseInt(line.substring(0, ind));
ind = line.indexOf(' ');
line = line.substring(ind);
line = line.trim();
ind = line.indexOf(' ');
int P = Integer.parseInt(line.substring(0, ind));
ind = line.indexOf(' ');
line = line.substring(ind);
line = line.trim();
int Diff = Integer.parseInt(line);
eq[i] = new Equipe(nom, i + 1);
eq[i].setPoints(Pts);
eq[i].addJournee(J);
eq[i].addGagnee(G);
eq[i].addNulle(N);
eq[i].addPerdu(P);
eq[i].addDiffBut(Diff);
i++;
}
}
}
tampon.close();
fich.close();
} catch (IOException e) {
System.err.println(nomFich + " - Erreur de lecture: " + e.toString());
}
} |
Que dois-je changer pour que lorsque je lance mon main, il ne me mette pas "fichier Test.txt introuvable" ?
PS: je suis désolée d'insister lourdement... 
Merci par avance
Aud-
Partager