entries[6]=artikelmarke;
            entries[7]=artikelkategoriename;
            entries[8]=""+kategorienummer;
            entries[9]=sortierung;

            if(flag)writer.writeNext(entries);
        
            
        }
        writer.close();

I create a CSV like this, but the last Linebreak adds an empty row at the end, which causes trouble in further processing. Anyone know how to avoid that?

enter image description here

有帮助吗?

解决方案

I'm guessing you're using CSVWriter. if you check source code for writeNext, it always adds new line at the end. The easiest solution without changing too much with your project, if files are not too big, is just to write into an in-memory stream, then flush it all into a file except the last new line character.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top