Author: echatellier Date: 2013-01-02 12:06:26 +0100 (Wed, 02 Jan 2013) New Revision: 43 Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/43 Log: Use ; separator Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/CsvWriter.java Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/CsvWriter.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/CsvWriter.java 2013-01-02 11:05:13 UTC (rev 42) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/CsvWriter.java 2013-01-02 11:06:26 UTC (rev 43) @@ -4,7 +4,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -33,32 +33,37 @@ public class CsvWriter { private final PrintWriter out; private boolean first = true; + public CsvWriter(OutputStream os) { - out = new PrintWriter(os); + out = new PrintWriter(os); } + public CsvWriter write(Object value) { - if (!first) { - out.append(","); - } - out.append("\""); - if (value != null) { - out.append(value.toString().replace("\"", "\"\"") - .replace("\n", " ")); - } - out.append("\""); - first = false; - return this; - } + if (!first) { + out.append(";"); + } + out.append("\""); + if (value != null) { + out.append(value.toString().replace("\"", "\"\"") + .replace("\n", " ")); + } + out.append("\""); + first = false; + return this; + } + public CsvWriter endLine() { - out.append("\r\n"); - first = true; - return this; + out.append("\r\n"); + first = true; + return this; } + public CsvWriter flush() { - out.flush(); - return this; + out.flush(); + return this; } + public void close() { - out.close(); + out.close(); } }