public static String arrayListToCSV ( List < String > list ) { StringBuilder csv = new StringBuilder ( ) ; for ( String str : list ) { csv . append ( str ) ; csv . append ( "," ) ; } int lastIndex = csv . length ( ) - 1 ; char last = csv . charAt ( lastIndex ) ; if ( last == ' ' ) { return csv . substring ( 0 , lastIndex ) ; } return csv . toString ( ) ; }
Converts String ArrayList to CSV string