Domanda

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

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top