سؤال

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