0

I'm creating a file that isn't really a csv file, but SuperCSV can help me to make the creation of this file easier. The structure of the file uses different lengths for each line, following a layout that don't separate the different information. So, to know which information has in one line you need look at the first 2 characters (the name of the register), count the characters and extract it by size.

I've configured SuperCSV to use empty delimiter, however, the created file is using a space where it should have nothing.

public class TarefaGerarArquivoRegistrosFiscais implements ITarefa {

    private static final CsvPreference FORMATO_ANEXO_IV = new CsvPreference.Builder('"', '\0' , "\r\n").build();

    public void processar() {
        try {
            writer = new CsvListWriter(getFileWriter(), FORMATO_ANEXO_IV);
            writer.write(geradorRegistroU1.gerar());
        } finally {
            if (writer != null)
                writer.close();
        }
    }
}

I'm doing something wrong? '\0' is the correct code for a null char?

4

1 回答 1

2

这可能不是您想听到的,但我不建议为此使用 Super CSV(而且我是提交者!)。它的唯一目的是处理分隔文件 - 而您没有使用分隔符。

您可以通过创建一个包装对象(包含您的列表)来滥用 Super CSV,该对象的toString()方法只是将所有值连接在一起,然后将该单个对象传递给writer.write(),但这是一个可怕的 hack。

我建议要么找到另一个更适合您的问题的库,要么编写您自己的解决方案。

于 2014-02-18T01:55:28.053 回答