Example #1
0
 /**
  * This function write a word gived in parameter to the end of the current file
  *
  * @param mot a word to write
  */
 public static void ecritureMot(String mot) {
   FichierR f = ouvrirDicoR();
   FichierW fi = ouvrirDicoW();
   if (f.equalsMots(mot)) {
     fi.introduireEspace();
     fi.ecrireString(mot);
   } else {
     System.out.println("Desole ce mot existe déjà dans le dictionnaire");
   }
 }
Example #2
0
  /**
   * This function read the dictionary and return a random word
   *
   * @return a random word
   */
  public static String lectureMots() {
    // Gestion des Flux I/O

    String str = "";
    FichierR fi = ouvrirDicoR();
    final int longueur = fi.longueurFichier();
    final int nbrRandom = nbrRandom(longueur);
    str = fi.lire(nbrRandom);
    fi.fermerFluxReader();
    return str;
  }
Example #3
0
 /**
  * This function open the dico with the path per default "res/data/dico_fr.txt"
  *
  * @return a file describing the dico
  */
 public static FichierR ouvrirDicoR() {
   String nomFichier = null;
   switch (choixDico) {
     case 1:
       nomFichier = "res/data/dico_fr.txt";
       break;
     case 2:
       nomFichier = "res/data/dico_en.txt";
       break;
   }
   FichierR f = new FichierR(nomFichier);
   f.ouvrirFluxReader();
   return f;
 }