Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top