1 pièce(s) jointe(s)
Aide Fichier Indexe et Sequeciel en JAVA
salut a tous ,
je suis e face d un exercice ou on doit utiliser ses 2 type de fichier
comme ce ci l exercice
il y a 2 probleme que j ai recontre
1-je ne sais comment mettre les variables comme nom a 10 caractere et 6 caractere ... , (comme en Vb.net <vbFixedString>)
2-lorque je creer le fichier Indexe Stagiare on l ajoute le code,nom,prenom,section ca se passe bien il se creer bien
mais lorsque je veux creer le fichier Modules de fichier sequeciel il ne reconnait pas le code de fichier Stagiare
voila mon code pour l instant
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 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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
import biputil2.*;
import java.io.*;
class Fichiersi {
static IndexedFile f=new IndexedFile();
static BufferedReader lire=new BufferedReader(new InputStreamReader (System.in));
public static void menu()throws IOException {
String rep="o";
while(rep.equalsIgnoreCase("o")){
System.out.println("--------------------------------------");
System.out.println("Ajouter Un Stagiare ");
System.out.println("Ajouter les notes d un Stagiare");
System.out.println("La Liste des Stagiare ");
System.out.println("Liste des Stagiares Par Module");
System.out.println("Le NOmbre de Stagiare dans le Fichier");
System.out.println("Calculer la moyenne Globale");
System.out.print("Entrez Votre Choix " );
int choix=Integer.parseInt(lire.readLine());
switch(choix){
case 1:Ajouti();
System.out.println("Tapez Entrer Pour Revenir Au Menu");
lire.readLine();
break;
case 2:Ajouts();
System.out.println("Tapez Entrer Pour Revenir Au Menu");
lire.readLine();
break;
}
}
}
public static void Ajouti()throws IOException {
String code,nom,prenom,section,ligne ;
String rep="o";
FileWriter fc=new FileWriter("c:\\Stagiares.txt");
PrintWriter sortie=new PrintWriter(fc);
f.open("c:\\Stagiares.txt");
do {
System.out.print("Entrez Votre Code " );
code=Keyboard.getString();
ligne=f.read(code);
if (f.InvalidKey){
System.out.print("Entrez Le Nom " );
nom=Keyboard.getString();
System.out.print("Entrez Votre Prenom " );
prenom=Keyboard.getString();
System.out.print("Entrez Votre Section " );
section=Keyboard.getString();
ligne=code+ " || " +nom+ " || " +prenom+ " || " +section;
sortie.println(ligne);
sortie.close();
}
else {
System.out.println(" ce Stagiare Existe deja");
}
System.out.println("Autre Saise o/n ");
rep=lire.readLine();
}while(rep=="o" || rep=="O");
f.close();
}
public static void Ajouts()throws IOException{
FileWriter fc1=new FileWriter("c:\\Modules.txt");
PrintWriter sortie1=new PrintWriter(fc1);
String code;
int CodeModule ;
double NoteMoyenne ;
String ligne ;
String rep="o" ;
do {
f.open("c:\\Stagiares.txt");
System.out.print("Entre votre Code " );
code=Keyboard.getString();
ligne=f.read(code);
if (f.InvalidKey){
System.out.print("ce stagiare N extes pas");
}
else {
System.out.println("Entre votre Code ");
code=Keyboard.getString();
System.out.println("Entre Votre code modules ");
CodeModule=Keyboard.getInt();
System.out.println("Entrez Votre NoteMoyenne " );
NoteMoyenne=Keyboard.getDouble();
ligne=code+ " || " +CodeModule+ " || " +NoteMoyenne;
sortie1.println(ligne);
sortie1.close();
}
System.out.println("Autre Saisie o/n ");
rep=lire.readLine();
}
while(rep=="o" || rep=="O");
}
public static void main (String[] args) throws IOException{
menu();
}
} |
merci pour l aide