From: Roland Haeder Date: Mon, 20 Jul 2015 12:54:36 +0000 (+0200) Subject: Introduced addContactToList() + used writeBytes() instead of writeCharacters() as... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=75aa72197c3b60ba733cfbaf2684de11e87c38fb;p=jfinancials-swing.git Introduced addContactToList() + used writeBytes() instead of writeCharacters() as this causes an empty char behind all written characters which breaks the parser Signed-off-by:Roland Häder --- diff --git a/Addressbook/src/org/mxchange/addressbook/database/backend/csv/CsvDatabaseBackend.java b/Addressbook/src/org/mxchange/addressbook/database/backend/csv/CsvDatabaseBackend.java index e191b31..750d60e 100644 --- a/Addressbook/src/org/mxchange/addressbook/database/backend/csv/CsvDatabaseBackend.java +++ b/Addressbook/src/org/mxchange/addressbook/database/backend/csv/CsvDatabaseBackend.java @@ -155,7 +155,33 @@ public class CsvDatabaseBackend extends BaseDatabaseBackend implements CsvBacken this.getLogger().debug(MessageFormat.format("str({0})={1}", str.length(), str)); // The string is now a valid CSV string - this.storageFile.writeChars(str); + this.storageFile.writeBytes(str); + } + + /** + * Adds given contact to list + * + * @param contact Contact instance to add + * @param list List instance + */ + private void addContactToList (final Contact contact, final List list) { + // Debug message + this.getLogger().debug(MessageFormat.format("contact={0}", contact)); + + // Is the contact read? + if (contact instanceof Contact) { + // Then add it + boolean added = list.add(contact); + + // Debug message + this.getLogger().debug(MessageFormat.format("contact={0} added={1}", contact, added)); + + // Has it been added? + if (!added) { + // Not added + this.getLogger().warn("Contact object has not been added."); + } + } } /** @@ -422,23 +448,8 @@ public class CsvDatabaseBackend extends BaseDatabaseBackend implements CsvBacken count++; } - // Debug message - this.getLogger().debug(MessageFormat.format("contact={0}", contact)); - - // Is the contact read? - if (contact instanceof Contact) { - // Then add it - boolean added = list.add(contact); - - // Debug message - this.getLogger().debug(MessageFormat.format("contact={0} added={1}", contact, added)); - - // Has it been added? - if (!added) { - // Not added - this.getLogger().warn("Contact object has not been added."); - } - } + // Add contact + this.addContactToList(contact, list); } // Return finished list