Exemple #1
0
  public static void loadFlashcards() {
    try {
      CSVReader reader =
          new CSVReader(new InputStreamReader(new FileInputStream(csvPath), "UTF-16"));

      String[] line;

      while ((line = reader.readNext()) != null) {
        flashcardSet.addFlashcard(new Flashcard(line[0], line[1]));
      }
    } catch (FileNotFoundException e) {
      JOptionPane.showMessageDialog(
          Main.frame, "No file found at " + csvPath, "File Not Found", JOptionPane.ERROR_MESSAGE);
    } catch (IOException e) {
      JOptionPane.showMessageDialog(
          Main.frame,
          "Unable to load from " + csvPath,
          "Unable to Read From File",
          JOptionPane.ERROR_MESSAGE);
    }
  }