Beispiel #1
0
 public Entry get(String word) // zwraca pozycjê zawieraj¹c¹ podane s³owo
     {
   for (Entry e : dict) {
     if (e.getWord().equals(word)) return e;
   }
   return null;
 }
 /**
  * The compare to method that compares if an Entry is less than, equal, or greater than another
  * entry which will assist in the insert method in BSTSimpleMap.
  *
  * @param other The Entry to be compared to
  * @return An integer whose value tells of the comparison.
  */
 @Override
 public int compareTo(Entry other) {
   if (other == null) {
     throw new NullPointerException();
   }
   return word.compareTo(other.getWord());
 }
Beispiel #3
0
  public void saveDB(String filename) // zapisuje baze s³ów do pliku
      {
    try {
      FileOutputStream fstream = new FileOutputStream(filename);

      DataOutputStream out = new DataOutputStream(fstream);
      BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out));

      for (Entry e : dict) {
        bw.write(e.getWord() + "\n");
        bw.write(e.getClue() + "\n");
      }

      bw.close();
    } catch (Exception e) {
      JOptionPane.showMessageDialog(null, e.getLocalizedMessage());
    }
  }