/** * Write the Anki Cards and Decks to the output file that was specified during initialization. * Each Card will be written as a line to the output file based on the CardWriter returned by the * CardWriterFactory * * @return true if writing succeeds, false otherwise. */ public boolean writeOutputFile() { try { writer = new BufferedWriter(new FileWriter(outputFilename)); Collection<Deck> parsedDecks = ankiFile.getParsedDecks().values(); Iterator<Deck> deckItr = parsedDecks.iterator(); while (deckItr.hasNext()) { Deck deck = deckItr.next(); Iterator<Card> cardItr = deck.getCardList().iterator(); while (cardItr.hasNext()) { Card card = cardItr.next(); String cardOutputLine = cardWriter.writeCard(card, deck); writer.write(cardOutputLine); } } writer.close(); writeSucceeded = true; return true; } catch (IOException ioe) { // record error messages String errorMessage = "An error occurred writing to the output file: " + this.outputFilename; addStatusMessage(errorMessage); writeSucceeded = false; return false; } }