From 75aa72197c3b60ba733cfbaf2684de11e87c38fb Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Mon, 20 Jul 2015 14:54:36 +0200 Subject: [PATCH] =?utf8?q?Introduced=20addContactToList()=20+=20used=20wri?= =?utf8?q?teBytes()=20instead=20of=20writeCharacters()=20as=20this=20cause?= =?utf8?q?s=20an=20empty=20char=20behind=20all=20written=20characters=20wh?= =?utf8?q?ich=20breaks=20the=20parser=20Signed-off-by:Roland=20H=C3=A4der?= =?utf8?q?=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../backend/csv/CsvDatabaseBackend.java | 47 ++++++++++++------- 1 file changed, 29 insertions(+), 18 deletions(-) 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 e191b31d..750d60ec 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 -- 2.39.5