java/rozsirene-atributy/src/cz/frantovo/rozsireneatributy/CSV.java
branchv_0
changeset 39 ec0e970e0830
parent 38 41e91ea94acb
child 40 1978eaf429de
     1.1 --- a/java/rozsirene-atributy/src/cz/frantovo/rozsireneatributy/CSV.java	Sat Dec 16 19:09:35 2023 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,65 +0,0 @@
     1.4 -/**
     1.5 - * Rozšířené atributy – program na správu rozšířených atributů souborů
     1.6 - * Copyright © 2023 František Kučera (frantovo.cz)
     1.7 - *
     1.8 - * This program is free software: you can redistribute it and/or modify
     1.9 - * it under the terms of the GNU General Public License as published by
    1.10 - * the Free Software Foundation, either version 3 of the License.
    1.11 - *
    1.12 - * This program is distributed in the hope that it will be useful,
    1.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    1.15 - * GNU General Public License for more details.
    1.16 - *
    1.17 - * You should have received a copy of the GNU General Public License
    1.18 - * along with this program. If not, see <http://www.gnu.org/licenses/>.
    1.19 - */
    1.20 -package cz.frantovo.rozsireneatributy;
    1.21 -
    1.22 -import java.io.IOException;
    1.23 -import java.io.Writer;
    1.24 -
    1.25 -/**
    1.26 - * Generátor standardních CSV.
    1.27 - *
    1.28 - * @author Ing. František Kučera
    1.29 - */
    1.30 -public class CSV {
    1.31 -
    1.32 -	private final Writer výstup;
    1.33 -	private int sloupec = 0;
    1.34 -	private int početSloupců = -1;
    1.35 -
    1.36 -	public CSV(Writer výstup) {
    1.37 -		this.výstup = výstup;
    1.38 -	}
    1.39 -
    1.40 -	public void hodnota(String hodnota) throws IOException {
    1.41 -		if (sloupec > 0) výstup.write(',');
    1.42 -		if (hodnota != null && !hodnota.isEmpty()) {
    1.43 -			výstup.write('"');
    1.44 -			for (char ch : hodnota.toCharArray()) {
    1.45 -				if (ch == '"') výstup.write('"');
    1.46 -				výstup.write(ch);
    1.47 -			}
    1.48 -			výstup.write('"');
    1.49 -		}
    1.50 -		sloupec++;
    1.51 -		výstup.flush();
    1.52 -	}
    1.53 -
    1.54 -	public void konecŘádku() throws IOException {
    1.55 -		if (početSloupců < 0) početSloupců = sloupec;
    1.56 -		if (sloupec == početSloupců) {
    1.57 -			výstup.write("\r\n");
    1.58 -			sloupec = 0;
    1.59 -		} else {
    1.60 -			throw new IOException("Neodpovídá počet sloupců:"
    1.61 -				+ " aktuální=" + sloupec
    1.62 -				+ " celkový=" + početSloupců
    1.63 -			);
    1.64 -		}
    1.65 -		výstup.flush();
    1.66 -	}
    1.67 -
    1.68 -}